如何使用主要联系人号码启动拨号器?
任何人都可以帮助我实现以下目标,
给定在之前的活动期间通过“ACTION_PICK”获得的联系人的 Uri,我想启动 ACTION_DIAL 意图来呼叫该联系人。
但不确定如何解决这个问题,我是否需要首先查询以查找与联系人关联的主要号码,或者是否有更简单的方法?我希望我可以使用联系人的 Uri 启动 ACTION_DIAL,它会自己找出要做什么,但这不起作用。
我们一如既往地感谢您的建议。
PS 此代码适用于 Froyo 及以上版本,因此使用 ContactsContract 而不是旧版本。
谢谢,
Can anyone help me achieve the following,
Given a Uri to a contact already obtained via an 'ACTION_PICK' during a previous activity, I want to launch an ACTION_DIAL intent to call the contact.
Not sure how to go about this though, do I first need to query to find the primary number associated with the contact or is there a simpler approach? I was hoping I could just launch ACTION_DIAL with the Uri of the contact and it would figure out what to do itself but that doesn't work.
Your advice as always is appreciated.
PS This code is for Froyo onwards, so using ContactsContract not the older stuff.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了其他人的利益,使用从 ACTION_PICK 意图获取的联系人的 URI 启动 ACTION_DIAL/ACTION_CALL 意图是行不通的。这是一个无效参数。
因此,我必须通过几个查询来确定联系人的电话号码。我也只寻找“主”电话。
我执行该任务的代码如下,也许我不需要执行初始查询来获取 ID,因为我已经有了 URI,但我还没有找到替代方案,所以如果有人可以提出其他建议,请让我知道:-),
www.dbws.net
Well for the benefit of others, launching ACTION_DIAL/ACTION_CALL intent with the URI for a contact obtained from an ACTION_PICK intent does not work. It's an invalid parameter.
So I had to determine the phone number for the contact via a couple of queries. I also only look for the 'Primary' telephone.
My code to do the task is as follows, Perhaps I don't need to do the initial query to obtain the ID as I have the URI already but I haven't figured out an alternative yet so if anyone can suggest otherwise please let me know :-) ,
www.dbws.net
它会帮助你,
it will help you,
添加
不要忘记在清单文件中
Don't forget to add
in Manifest file