提醒当两个用户/朋友都接近对方 - Android的接近 [英] Alert when two users/friends are near to each other - Android Proximity
问题描述
我试图寻找,但我无法找到任何东西。
我的问题是如何提醒2个或更多的用户,如果他们是附近的对方?在Android中使用地理围栏或别的东西。
I tried searching but i couldn't find anything. My Question is "How can i alert 2 or more users if they are nearby each other?" in android using Geo-fencing or something else.
我说,如果用户A在足球场和用户B在附近散步的足球场。然后a和UserB自动获得通知用户a /用户B都在附近的某个地方。
Say, If a UserA is in football ground and UserB walking nearby that football ground. Then UserA and UserB automatically gets notification that UserA/UserB are somewhere nearby.
推荐答案
最后花了几个小时后,思想,我认为更好的方法来做到这一点:
Finally after spending a couple of hours thinking, I thought a better way to do this:
-
设置数据库(MySQL和SQL等)在您的服务器具有用户表,位置表具有的位置数据
Setup a database (MySQL,SQL etc) in your server which have users table and location table which have the locations data
在Android的创建服务,将在15分钟内发射一次请求的当前位置。
In Android create a Service which will fire once in 15 minutes requesting current location.
创建共享preference / SQliteDB持有的装置,该装置也更新到数据库服务器的最后一个坐标。
Create SharedPreference / SQliteDB which holds the last Coordinates of the device which was also updated to the Server database.
3.1 如果
当前位置从共享preference检索到的最后一个位置匹配和/或
电流在位置x
接近(取决于你给多少 X
30英尺以上)
结果然后
用户在同一个地方的所以没有上传坐标到服务器数据库
3.1 If
the current location matches the Last Location retrieved from the SharedPreference and/or
current location within x
proximity (depends on how much you give x
30ft or more)
then
user is in the same place so don't upload the coordinates to the Server Database.
3.2。 如果
用户不是内接近或
最后一个位置不符合当前的位置 - 然后
上传坐标到服务器数据库。
3.2. If
the user isn't within proximity or
last location doesn't match current location then
upload the coordinates to the Server Database.
上传坐标到服务器后,更新共享preference太...
After uploading coordinates to the server, update SharedPreference too...
上传坐标后,服务器必须返回从其数据库是你的接近度之内谁的用户详细信息。然后,您的应用程序知道你是谁靠近,并通知你说你的好友XXX就在附近!
After uploaded coordinates, The Server must return the User details from its database who are within your proximity. Your app then knows who are near you and send notification to you saying "Your buddy XXX is nearby!"
在服务器,上传坐标后,服务器也将通知发送给在附近,使用谷歌云消息谁的用户。
In Server, after uploading your coordinates, the server will also send notification to the user who are nearby you using Google Cloud Messaging.
提示:运行在服务器cron作业将执行每分钟,并检查谁靠近谁,并通知他们的
Tips: Run a cron job in your server which will execute every minute and checks "Who is near to Who" and send notification to them.
希望它可以帮助别人:)
Hope it helps somebody :)
这篇关于提醒当两个用户/朋友都接近对方 - Android的接近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!