Android 电话号码选择器
我想打电话给电话簿,让用户选择一个(或多个可选)电话号码(我只需要电话号码,而不需要整个联系人信息,因为我想让用户跳过自己写号码并选择一个)。这是我到目前为止发现的:
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
这会返回一个选定的联系人,但它可能没有或有很多电话号码(而且我不需要全部电话号码。我只需要一个。我可以让用户使用 ListView 或Spinner,但我相信一定有一些 API,因为我手机上的消息应用程序有这样的选择器(嗯,可能会更舒服,但我认为它是一个 API,而不是消息应用程序)。
I want to call phones book to let user to pick one (or multiple optionally) phone numbers (I need only phone numbers and not the whole contacts info because I want to let the user to skip writing the number himself and pick one instead). This is what I found so far:
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
This returns me a contact selected but then it might have no or many phone numbers (and I don't need them all. I need just one. I could let the user to choose it using ListView or Spinner but I believe there must be some API for that because Messages app on my phone has such picker (well, could be more comfortable but I assume it's an API and not the Messages app).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以使用 API 实现,请参阅:
https://developer.android.com/guide/components/intents- common.html#联系人
他们的示例意图片段:
您可以在上面链接的文档中看到他们如何处理结果。
This is possible using the APIs, see:
https://developer.android.com/guide/components/intents-common.html#Contacts
A snippet of their example intent:
You can see how they handle the result in the docs linked above.