我怎样才能让我的WhatsApp的号码? [英] How can I get my whatsapp number?

查看:308
本文介绍了我怎样才能让我的WhatsApp的号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发Android应用程序,并希望阅读客户端设备配置的WhatsApp的电话号码。

I am developing an app for Android and want to read the whatsapp telephone number configured in the client device.

试过以下code:

AccountManager am = AccountManager.get(this);
Account[] accounts = am.getAccounts();

for (Account ac : accounts) {
    String acname = ac.name;
    String actype = ac.type;
    // Take your time to look at all available accounts
    System.out.println("Accounts : " + acname + ", " + actype);
}

if(actype.equals("com.whatsapp")){
    String phoneNumber = ac.name;
}

我还设置此权限:<使用许可权的android:NAME =android.permission.GET_ACCOUNTS/>

但phoneNumber的只返回WhatsApp的

but phoneNumber only returns "Whatsapp"

我需要用户的WhatsApp的电话号码在我的数据库中的记录。我怎样才能得到这个电话号码吗?

I need the user's whatsapp phone number as a record in my database. How can I get this phone number?

推荐答案

请按照下列步骤操作:


  1. 您需要一个接触的WhatsApp的 rawcontact ID。

  2. 查询 ContactsContract.Data MIME类型=vnd.android.cursor.item / vnd.com.whatsapp.profile rawcontact ID。

  3. DATA3 列是WhatsApp的数量。

  1. You need the rawcontact id of WhatsApp of that contact.
  2. Query ContactsContract.Data table with mimetype = "vnd.android.cursor.item/vnd.com.whatsapp.profile" with that rawcontact id.
  3. The DATA3 column is the number of WhatsApp.

这篇关于我怎样才能让我的WhatsApp的号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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