1

This work fine..

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

But, when i try this..

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

i got this error..

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 }

is there actually a SMS Picker? because i don't want to load all the message to my app, i just want to pick it directly from android default sms app.. please help.. thx..

Riky
  • 13
  • 4
  • "is there actually a SMS Picker?" - No, there's not. – Mike M. Mar 27 '17 at 03:32
  • @MikeM. Because my client have like 6000sms and it make the app freeze/force close.. so i think it will best if he can directly select mesage from default android sms app.. btw.. for case like this, any best solution to do that? .. thx.. – Riky Mar 27 '17 at 03:37
  • There is not picker available. What do you actually want to achieve do want to read the messages or you want to send some text inside message app? – VikasGoyal Mar 27 '17 at 03:37
  • @Avi the client want to select message for display it in edittext.. – Riky Mar 27 '17 at 03:40
  • for that you can fetch all the messages and create own picker because message app don't provide PICK behaviour you can only send message through that. – VikasGoyal Mar 27 '17 at 03:45
  • @Avi he has so many message like 6000sms and it make the app freeze/force close, any solution for that ? or it's possible to use pagination when retrieving message? – Riky Mar 27 '17 at 03:47
  • Please refer the provided answer – VikasGoyal Mar 27 '17 at 03:52

1 Answers1

0

Message app don't provide PICK behavior you can only send the message through that

To read Message from android device you can find a good in these links

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));

Please refer the above query and in each pagination offset will be start index and limit will be the count of data you want to fetch.

Community
  • 1
  • 1
VikasGoyal
  • 3,308
  • 1
  • 22
  • 42
  • You can use pagination in cursor query by providing LIMIT %s OFFSET %s. – VikasGoyal Mar 27 '17 at 03:50
  • if i have a list for 50sms, and next next i scroll the list down and it's automatic add more 50sms, what widget i can use for that purpose? thx... – Riky Mar 27 '17 at 04:01
  • You can use recyclerView and when you about to reach on end you can call for next data from you SMS helper. – VikasGoyal Mar 27 '17 at 04:15
  • In recyclerView on layout manager you can listen for onScroll listener and there you can find the the current visible item after putting some calculation you can easily found out you list is about to reach on end. – VikasGoyal Mar 27 '17 at 04:16
  • so using this recyclerview... 1. If i pull down, i add new message where _id > than first item on the list... is this possible? – Riky Mar 27 '17 at 04:28
  • 2. If i scroll down to the end, i add 50new message where id< than last item on the list.. is this possible? Thx vi.. – Riky Mar 27 '17 at 04:29
  • or you can register your app for message received in Android system so you won't need to handle new messages in query. – VikasGoyal Mar 27 '17 at 04:34
  • To listen for SMS you can find a solution here:- http://stackoverflow.com/a/7171785/1562659 – VikasGoyal Mar 27 '17 at 04:34
  • wow.. that's great.. i will try it,, any great example for add data on the end of recyclerview list so i don't need to refresh the entir list? thx.. – Riky Mar 27 '17 at 04:36