有一个短信选取器,如Contact Picker Android?

时间:2017-03-27 03:31:21

标签: android

这项工作很好......

Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"));
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivity(intent);

但是,当我试试这个..

Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://sms/inbox"));
    intent.setType(Telephony.Sms.Inbox.PERSON);
startActivity(intent);

我收到了这个错误..

E/InputEventReceiver: Exception dispatching input event.
E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK typ=person }

实际上是否有短信寻求者? 因为我不想将所有消息加载到我的应用程序,我只想直接从Android默认短信应用程序中选择它。 请帮忙.. thx ..

1 个答案:

答案 0 :(得分:0)

消息应用程序不提供PICK行为,您只能通过该

发送消息

要阅读来自Android设备的消息,您可以在这些链接中找到好消息

Read messages from device-1

Read messages from device-2

Cursor cursor = context.getContentResolver().query(
                      SMS_INBOX_CONTENT_URI,
                      new String[] { "_id", "thread_id", "address", "person", "date", "body" },
                      WHERE_CONDITION,
                      null,
                      SORT_ORDER + String.format(" LIMIT %s OFFSET %s", limit, offset));

请参考上面的查询,在每个分页中,偏移量将是起始索引,限制将是您要获取的数据的数量。