Created
March 2, 2014 23:36
-
-
Save hughes/9315684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String makeMessageStr(HashMap<String, String> messageHash) { | |
String from_number = messageHash.get("from_number"); | |
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(from_number)); | |
Cursor people = getContentResolver().query(uri, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null); | |
int indexName = people.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); | |
String name = from_number; | |
if (people.getCount() > 0) { | |
people.moveToFirst(); | |
do { | |
name = people.getString(indexName); | |
Log.v("VP", "Found name: " + name); | |
} while (people.moveToNext()); | |
} else { | |
Log.v("VP", "No contacts found"); | |
} | |
String message = name; | |
try { | |
Date date = ISO8601.toCalendar(messageHash.get("created_at")).getTime(); | |
message += " - " + dateFormat.format(date); | |
} catch(ParseException e) { | |
Log.e("VP", "Datetime parse error", e); | |
} | |
Log.v("VP", message); | |
return message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment