我怎样才能让我的WhatsApp的号码? [英] How can I get my whatsapp number?
本文介绍了我怎样才能让我的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?
推荐答案
请按照下列步骤操作:
- 您需要一个接触的WhatsApp的
rawcontact
ID。 - 查询
ContactsContract.Data code>表
MIME类型=vnd.android.cursor.item / vnd.com.whatsapp.profile
与rawcontact
ID。 - 的
DATA3
列是WhatsApp的数量。
- You need the
rawcontact
id of WhatsApp of that contact. - Query
ContactsContract.Data
table withmimetype = "vnd.android.cursor.item/vnd.com.whatsapp.profile"
with thatrawcontact
id. - The
DATA3
column is the number of WhatsApp.
这篇关于我怎样才能让我的WhatsApp的号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文