While working with Android Contact ContentProvider. We have a Phone Number and we need to get the URI of the Photo of the contact associated with this phone number With the below code we can get the Contact iMage from Phone Number With the below code we can get the Name of the Contact
String imnage;
Cursor phonesCursor;
try {
Uri phoneUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode("Pass here phone number"));
phonesCursor = getContentResolver().query(phoneUri, new String[]{ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI}, null, null, null);
} catch (NullPointerException e) {
e.printStackTrace();
}
catch (IllegalArgumentException e){
e.printStackTrace();
}
if (phonesCursor != null && phonesCursor.moveToFirst()) {
imnage = phonesCursor.getString(0);
try {
img_profile.setImageURI(Uri.parse(imnage));
}catch (NullPointerException e){
e.printStackTrace();
}
// displayName = phonesCursor.getString(0); // this is the contact name
} else {
Log.e("no contact ", "============");
}
String str2 = null;
Cursor query = getContentResolver().query(Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(str)), new String[]{"display_name"}, null, null, null);
if (query != null) {
if (query.moveToFirst()) {
str2 = query.getString(query.getColumnIndex("display_name"));
}
if (query != null && !query.isClosed()) {
query.close();
}
}
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
How to extract date and time from Long type variable in Kotlin on Android "
What is the difference between match_parent and fill_parent?
What is Application?
How to check Android version?
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
How to start a new activity on button click
Hide/Disable soft keyboard on Activity launch: Android
How to add jar/library files as a dependency in Android studio gradle file
How to Generate signed apk with android studio
How to get an image resource by it's name in android?
How To Set Text Color Programmatically Android TextView?
How to reduce APK package size?
What is Android?
How to Get bitmap from drawable: Android
What is the Different Between val and var in Kotlin?
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
What happens next when the device switches between portrait and landscape?
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
What is Android Fragments?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How can i comment inside xml file in android studio?
ERR_ACCESS_DENIED in Android Webview with sdk 30
How to save activity State in Android?
How to convert milli seconds to hours, minutes and seconds in Android?
Permission denied for window type 2010 in Marshmallow device
How do I generate random numbers in Dart?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
How to stop EditText focus at Activity startup in Android?
What is "shared preferences" in Android ?
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
Android Activity FullScreen - How to set activity to fullscreen mode in Android?
How to get screen size (width,height) in Android?
Check List for Generate Signed APK Android
How do i load image from drawable folder in Jetpack Compose?
What is Intent? What is the difference between an implicit intent and an explicit intent?
What are symmetric and asymmetric encryption in the way Android interacts with the server?
How to avoid multiple button click at same time in android?
What are the notifications available in android?
What is Context?