Quantcast
Channel: How to Fetch and Display Name and Image of Conversation's Contact? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to Fetch and Display Name and Image of Conversation's Contact?

$
0
0

I want to achieve something like in screenshot below, So far I am able to display a list of most recent message with message count, But when I'm trying to get the name of person through "address", I'm getting error " Column address not found".Please help me displaying "contact name with their image".

What I Want to Achieve

    @Override    public View onCreateView(LayoutInflater inflater, ViewGroup container,                     Bundle savedInstanceState) {            View view = inflater.inflate(R.layout.MyChatFragment, container, false);    // Inflate the layout for this fragment    ListView lv = (ListView) view.findViewById(R.id.listView2);    ArrayList<String> smsList;            smsList = new ArrayList<>();    ArrayAdapter<String> lva = new ArrayAdapter<String>(getActivity(),     android.R.layout.simple_list_item_1, smsList);            lv.setAdapter(lva);    Uri inboxUri = Uri.parse("content://sms/conversations/");    ContentResolver contentResolver = getActivity().getContentResolver();    Cursor cursor = contentResolver.query(inboxUri, null, null, null, null);    if (cursor.moveToFirst()) {            while (cursor.moveToNext()) {        String number = cursor.getString(cursor.getColumnIndexOrThrow("address"));        String message_count = cursor.getString(cursor.getColumnIndexOrThrow("msg_count"));        String body = cursor.getString(cursor.getColumnIndexOrThrow("snippet"));        smsList.add("Number: " + number +"\n" +"Message: " + body +"\n" +"Number Of Messages" +        message_count );            }        }            return view;     }

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images