i have working with small android application in this application i am try to get contact which used whats app application and also alert for my selected whats app contact from my application when contact updates his/her profile picture and status.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
由
翻译强力驱动
问题:
回答1:
You can query your content cursor to see what properties contacts have.
Cursor c1 = appActivity.getContentResolver().query( ContactsContract.Data.CONTENT_URI ,null,null,null, null); c1.moveToFirst(); DatabaseUtils.dumpCursor(c1); c1.close();
Or specifically if you want to query for whatsapp contacts here are the properties:
- You can query for
ContactsContract.RawContacts.ACCOUNT_TYPE
with value com.whatsapp - You can use
MIMETYPE
with value vnd.android.cursor.item/vnd.com.whatsapp.profile
Example:
c = appActivity.getContentResolver().query( ContactsContract.Data.CONTENT_URI ,new String[] { ContactsContract.Contacts.Data._ID } ,"mimetype=?", new String[] { "vnd.android.cursor.item/vnd.com.whatsapp.profile" }, null); c1.moveToFirst(); DatabaseUtils.dumpCursor(c1); c1.close();
Note (@Ragnar): MIMETYPE
column didn't work for me. I used ACCOUNT_TYPE
column and it worked.