如何从小部件显示 QuickContact 卡
我有一个小部件,可以显示我的一些联系人的图片,我想在用户点击其中一张图片时显示 QuickContact 卡。我知道我应该使用 ContactsContract.QuickContact.showQuickContact() 方法,但它需要视图或矩形作为输入参数之一。我的问题是小部件只有 RemoteViews,所以我不确定要传递什么作为 View 或 Rect 参数。任何想法将不胜感激。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要通过小部件显示 QuickContact UI,您可以使用此处说明的技术进行回调 PendingIntent:
http://advback.com/android/working-with-app-widgets-android/
在您的小部件 onUpdate() 中,创建意图并将其与 RemoteView 关联:
单击视图时,您将在小部件中收到 onReceive() 通知。使用 Intent.getSourceBounds() 检索矩形,并显示 QuickContact:
To show the QuickContact UI over a widget, you can make a callback PendingIntent using the technique illustrated here:
http://advback.com/android/working-with-app-widgets-android/
In your widget onUpdate(), create the intent and associate it with the RemoteView:
When the view is clicked, you'll get an onReceive() notification in your widget. Use Intent.getSourceBounds() to retrieve the rect, and show the QuickContact:
您可以在 XML 中引用徽章
我在 XML 文件中有这个:
和此代码:
这是调用模式(但是单击徽章正在处理此弹出窗口,此调用也是弹出窗口,选择器是通过单击某些内容进行的别的)
You can reference the badge in the XML
I have this in the XML file:
and this code:
and this is the calling mode (but the click on the badge is handling this popup, this call too popup the chooser is made by clicking on something else)
我也一直在寻找这个。也许通讯录应用程序的来源会有所帮助。我正在尝试挖掘: 链接文本
I've been looking for this as well. Maybe the source of the Contacts app will be helpful. I'm trying to digg in: link text
我也为此苦苦挣扎了一段时间。查看 Android 源代码,Google 似乎创建了一个名为 QuickContactActivity 的透明活动,并将 QuickContactWindow(创建弹出窗口的类)放置在其中。我尝试了同样的操作,透明活动确实有效,但我无法显示徽章。我了解 Qberticus 的 QuickActions 代码,并且确实尝试过,但我宁愿只使用 google 编写的 Quickcontacts,因为复制其功能和外观非常具有挑战性。
当我尝试在 Eclair 上使用 QuickContact.showQuickContact() 方法时,我也遇到了 ActivityNotFoundException - 不过它在 Froyo 上效果很好。
这是我的问题。如果我们能够共同努力解决这个问题,那就太棒了:链接
I've been struggling with this for some time now too. Looking at the Android source code, it appears that Google made a transparent activity called QuickContactActivity and placed the QuickContactWindow (the class that creates the popup) inside of that. I tried the same thing and the transparent activity does work but I'm having trouble getting the badge to show up. I know about Qberticus's QuickActions code and I did try it out but I'd rather just use the quickcontacts that google wrote because to duplicate its functionality and looks is pretty challenging.
I've also been getting ActivityNotFoundException when I try to use the QuickContact.showQuickContact() method on Eclair - it works great on Froyo though.
Here's my question. It would be really awesome if we could work together to get this issue solved: link