List Of Mimetypes Supported By Android Contacts
I am preparing a contact app where i need to get the list of Mimetypes supported by android contacts. For ex: Some devices support SIP address and some devices. So i want to insert
Solution 1:
If you want to check a mimetype is supported by a device - here is what you would do
Uri entityUri =
Uri.withAppendedPath(
ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), Entity.CONTENT_DIRECTORY);
Cursor c =
getContentResolver().query(
entityUri,
new String[] {
RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1 },
null, null, null);
try {
while (c.moveToNext()) {
String sourceId = c.getString(0);
if (!c.isNull(1)) {
String mimeType = c.getString(2);
String data = c.getString(3);
PackageManager packageManager = context.getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType(mimeType );
if (packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
// do something - it is supported
} else {
return false;
}
}
}
} finally {
c.close();
}
Post a Comment for "List Of Mimetypes Supported By Android Contacts"