2015-04-06 101 views
0

我正在準備聯繫人應用程序,我需要獲取Android聯繫人支持的Mimetypes列表。 例如:某些設備支持SIP address和某些設備。 所以我想插入SIP地址,當它被支持,那麼如何檢查mimetype是否受支持。 我在com.android.providers.contacts包中找到了android的聯繫人數據庫中的mimetypes表。 我將如何訪問contacts2.d b數據庫中的mimetypes表。Android聯繫人支持的Mimetypes列表

請幫忙。 謝謝你的幫助。

+0

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

+0

對不起,但我不想與mimetype關聯的聯繫人。我想設備支持的mimetypes列表@Abhi –

回答

0

如果你想檢查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表,所以我如何訪問它.. –