Back to project page texting.
The source code is released under:
Free to use, distribute, do anything.
If you think the Android project texting listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.skk.texting.factory; /*from w ww. j ava2 s . com*/ import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract; import com.google.inject.Inject; import com.skk.texting.domain.Person; public class PersonFactory { private ContentResolver contentResolver; @Inject public PersonFactory(ContentResolver contentResolver) { this.contentResolver = contentResolver; } public Person fromAddress(String address) { Person person = new Person(); person.setAddress(address); if (address != null && !address.isEmpty()) { Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(address)); Cursor cursor = contentResolver.query(uri, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null); if (cursor.moveToFirst()) { person.setName(cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME))); } } return person; } }