Android如何以编程方式获取使用whats应用程序的联系人列表 [英] Android how to get contact list which used whats app application programmatically

查看:38
本文介绍了Android如何以编程方式获取使用whats应用程序的联系人列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此应用程序中使用了小型 android 应用程序,我尝试获取使用 whats 应用程序应用程序的联系人,并在联系人更新他/她的个人资料图片和状态时从我的应用程序中提醒我选择的 whats 应用程序联系人.

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.

推荐答案

您可以查询内容光标以查看联系人具有的属性.

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();

或者特别是如果你想在这里查询 whatsapp 联系人是属性:

Or specifically if you want to query for whatsapp contacts here are the properties:

  • 您可以使用值 com.whatsapp
  • 查询 ContactsContract.RawContacts.ACCOUNT_TYPE
  • 您可以使用 MIMETYPE 的值 vnd.android.cursor.item/vnd.com.whatsapp.profile

示例:

 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();

注意 (@Ragnar):MIMETYPE 列对我不起作用.我使用了 ACCOUNT_TYPE 列并且它有效.

Note (@Ragnar): MIMETYPE column didn't work for me. I used ACCOUNT_TYPE column and it worked.

这篇关于Android如何以编程方式获取使用whats应用程序的联系人列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆