I want to fetch and view sms conversations?

前端 未结 5 866
天命终不由人
天命终不由人 2020-12-08 01:10
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(Uri.parse(\"content://sms/conversations/\"), null,null,null, null);     

is not wo

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 02:08

    This function is for fetching conversations

    private void getSMSCOnversationlist() {
        Uri SMS_INBOX = Uri.parse("content://sms/conversations/");
        Cursor c = getActivity().getContentResolver().query(SMS_INBOX, null,null, null, "date desc");
    
        String[] count = new String[c.getCount()];
        String[] snippet = new String[c.getCount()];
        String[] thread_id = new String[c.getCount()];
    
    
        c.moveToFirst();
        for (int i = 0; i < c.getCount(); i++) {
    
             count[i] = c.getString(c.getColumnIndexOrThrow("msg_count")).toString();
            thread_id[i] = c.getString(c.getColumnIndexOrThrow("thread_id")).toString();
            snippet[i] = c.getString(c.getColumnIndexOrThrow("snippet")).toString();
            Toast.makeText(getActivity(), count[i] + " - " + thread_id[i] + " - " + snippet[i]+ " - " , Toast.LENGTH_LONG).show();
            c.moveToNext();
    
        }
        c.close();
    }
    

提交回复
热议问题