Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // RETRIEVE LATEST SMS FROM CONTACTS WHO SENT SMS
- String folder = "content://sms/inbox/";
- Uri mSmsQueryUri = Uri.parse(folder);
- List<String> messages = new ArrayList<String>();
- try{
- Cursor c = context.getContentResolver().query(mSmsQueryUri, null, null, null, null);
- if(c == null){
- Log.i(TAG, "cursor is null. uri: " + mSmsQueryUri);
- }
- contactName = data.get(position);
- for(boolean hasData = c.moveToFirst(); hasData; hasData = c.moveToNext()){
- final String body = c.getString(c.getColumnIndexOrThrow("body"));
- messages.add(body);
- }
- }catch(Exception e){
- Log.e(TAG, e.getMessage());
- }finally{
- c.close();
- }
- holder.latestSMS.setText(messages.get(position)); // Displays last message in listview per contact
- //END RESULT: within my listview, it displays the just like the inbox on your device of all
- // SMS from all contacts who sent a message.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement