且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用同一应用程序检测附近的Android设备

更新时间:2022-01-15 07:15:31

免责声明:我不是android开发人员,但这似乎是设计问题,不是实现问题,因此希望我在下面的评论可能有一定用处...

Disclaimer: I'm not an android developer, but this seems like a design issue not a implementation issue so hopefully my comments below might be of some use...

我不认为可以将API设置为"true"来获得此功能,因此我认为您将必须定制所有运动部件(并且有几个).我认为总体过程将是这样的:

I don't think there's an API that you can just set to "true" to get this functionality, so I think you're going to have to custom craft all the moving parts (and there are a couple). I would think the general process would be something like:

  1. 客户端上的用户以某种身份(即"user@gmail.com")登录服务器
  2. 客户端应用每隔X分钟获取当前位置(即"100N 90E")并将其发送到服务器
  3. 客户端每隔X分钟轮询服务器以查看谁在10英里范围内(即"joe@gmail.com","mary@gmail.com")

在服务器上:

  1. 需要某种身份验证端点才能获取用户的身份
  2. 需要一个端点供用户注册其位置("user@gmail.com位于100N 90E")
  3. 需要一种服务来找出每个用户之间的距离
  4. 需要端点返回X英里内的用户(由#3生成的列表)

这些步骤中的每一个都不是一件容易的事,如果您愿意的话,您实际上可以在服务器步骤3上使用分发算法获得一些好处.

Each one of these steps shouldn't be difficult on their own and you can actually get pretty nuts with the distribution algorithm on server step #3 if you wanted to.

您可以问自己一些问题:

Some questions you can ask yourself are:

  • 如何设置服务器以侦听HTTP请求?" -查看Node.JS以获得简单的解决方案
  • 如何在android中获取用户的位置?" -简易的Google搜索可找到大量文档
  • 如何编写服务以连续执行操作?" -Node.JS会再次为此提供帮助
  • 我将在哪里存储用户的位置及其彼此之间的距离?" -您可以查看NoSQL选项,例如CouchBase或MongoDb.或者,您可以将MySQL用于更结构化的数据库.

希望这对您有帮助...

Hope this helps...