简体   繁体   English

android检查联系人是否安装了android应用(例如whatsapp)

[英]android check if a contact installed an app android (like whatsapp)

I want to let my app scan the users contactlist , and display the name of the contacts who also installed the app. 我想让我的应用扫描用户的contactlist,并显示也安装了该应用的联系人的姓名。

I have no idea where to begin with this . 我不知道从哪里开始。 so if someone could help me getting started , that would be apreciated. 因此,如果有人可以帮助我入门,那将不胜感激。

grtz grtz

You will need to research ContentResolver because you will have to query the database containing the contacts. 您将需要研究ContentResolver,因为您将不得不查询包含联系人的数据库。 To do these queries, you will need the URI and column/header names for contacts db which can be found in the Contacts class. 要进行这些查询,您将需要Contacts数据库的URI和列/标题名称,这些名称可以在Contacts类中找到。

You will also need users to register that they have your app on your own servers and the registration will need a piece of information about the user that other users would have in their contacts (the users phone number, email address, etc). 您还将需要用户进行注册,以确保他们在自己的服务器上拥有您的应用程序 ,并且注册将需要与其他用户在其联系人中拥有的用户有关的一条信息 (用户的电话号码,电子邮件地址等)。

You will then need to query a few users at a time from the users contacts for this piece of information (using the ContentResolver and Contacts class) , pass it to your server (as text) where it will check if they are registered, then send a message back to initial user (and possibly the match) that you found a match. 然后,您将需要一次从用户联系人中查询一些用户以获取此信息(使用ContentResolver和Contacts类) ,并将其传递到您的服务器(作为文本),服务器将在其中检查他们是否已注册,然后发送一条消息返回给初始用户(可能还有匹配项),说明您找到了匹配项。

That's where you should start, and end :) 那是你应该开始和结束的地方:)

Note, you will need these permissions in the Manifest file: 注意,您需要在清单文件中拥有以下权限:

android.permission.INTERNET
android.permission.READ_CONTACTS

First of all, welcome to StackOverflow. 首先,欢迎使用StackOverflow。 StackOverflow is for programming questions. StackOverflow用于编程问题。 As is such, a post asking for help should always provide a description of what you have already tried . 这样,寻求帮助的帖子应始终提供您已经尝试过的内容的描述。 If you haven't tried anything yet, I highly encourage you to try something, and post when you encounter a problem. 如果您还没有尝试过,我强烈建议您尝试一下,并在遇到问题时发帖。

As your question stands now, we don't know what the problem is. 正如您现在提出的问题一样,我们不知道问题出在哪里。 Are you having problems scanning a contact list? 您在扫描联系人列表时遇到问题吗? Or are you having problems trying to figure out if another user has installed the app? 还是您在尝试确定其他用户是否已安装该应用程序时遇到问题?

That being said, you will have to maintain a database for your app containing a list of people who have installed your app. 话虽如此,您将必须为您的应用程序维护一个数据库,其中包含已安装您的应用程序的人员的列表。 When your app is launched on one device, do whatever you need to do to register the user in your database. 当您的应用程序在一台设备上启动时,请执行将用户注册到数据库中所需的所有操作。 Due to the nature of a "contact," one person's phone may only have their phone number, email address, or even just a name. 由于“联系人”的性质,一个人的电话可能只有其电话号码,电子邮件地址,甚至只有一个名字。 This is of course something you will have to deal with in your implementation. 当然,这是您在实现中必须处理的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM