Android Intent 启动适当的聊天客户端
在我的应用程序中,我想提供一个聊天按钮。在特定联系人的上下文中,系统会向用户显示可用的联系方法列表。例如,它可能会列出 Google Talk ID 和 AIM ID。用户可以单击任一 ID,它应该启动处理所选聊天协议(如果已安装)的相应应用程序。鉴于我有协议和 ID(例如,PROTOCOL_GOOGLE_TALK 和“JohnDoeGtalk”),我如何创建执行此操作的意图?
谢谢。
In my application, I'd like to provide a Chat button. In the context of a specific contact, the user is shown a list of the contact methods available. For example, it might list a Google Talk ID and an AIM ID. The user can click on either ID and it should launch the appropriate application that handles the selected chat protocol (if one is installed). Given that I have the protocol and the ID (e.g., PROTOCOL_GOOGLE_TALK and "JohnDoeGtalk"), how can I create an intent that does that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过在 URI 中添加@gmail.com?
以下方法取自此处,有效为我;它使用 Google Talk 应用程序打开与联系人的新聊天。使用 HTC Desire 运行 Froyo。代码:
Have you tried adding @gmail.com in your URI?
The following approach, taken from here, works for me; it opens a new chat with the contact, using the Google Talk app. Using HTC Desire running Froyo. Code:
带有
Uri
且方案为imto://...
的ACTION_SENDTO
Intent
可能有效。请参阅此问题和评论 #2 了解明显有效的语法。请注意,我还没有尝试过这个,而且这个问题是很久以前的事了。An
ACTION_SENDTO
Intent
with aUri
whose scheme isimto://...
may work. See this issue and comment #2 for the apparently-valid syntax. Note that I have not tried this, and this issue is from quite some time ago.