Android联系人支持的Mimetypes列表

问题描述:

我正在准备联系人应用程序,我需要获取Android联系人支持的Mimetypes列表。 例如:某些设备支持SIP address和某些设备。 所以我想插入SIP地址,当它被支持,那么如何检查mimetype是否受支持。 我在com.android.providers.contacts包中找到了android的联系人数据库中的mimetypes表。 我将如何访问contacts2.d b数据库中的mimetypes表。Android联系人支持的Mimetypes列表

请帮忙。 谢谢你的帮助。

+0

http://*.com/questions/8942298/get-contacts-by-mime-type -in-android – Abhi

+0

对不起,但我不想与mimetype关联的联系人。我想设备支持的mimetypes列表@Abhi –

如果你想检查MIME类型的设备支持 - 这里是你会做什么

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(); 
} 
+0

但我没有任何以前存储的联系人洙我怎么能添加rawContactId。 –

+0

所以你没有联系人,但你想找出Android联系人支持的MiMETypes? – Abhi

+0

是的。它在联系人数据库中有Mimetypes表,所以我如何访问它.. –