android - limit one area and browse other people are using the same app -
when app triggered, takes current position of user through gps (this function implemented).
my question is: want know example if have users using app in given radius (1km example). possible?
yes, need server well. broadly speaking, process follows:
- the app gets location android.
- the app queries server, sending current location in request.
- the server stores location , user name in spatial database; is, database of users can indexed location. overwrites previous location if there one. server should store time location set.
- the server looks location in spatial database find users in given radius, or nearest n users. sends list of users app. might use json, xml, or other format send these data. (since control both server , app, can choose whatever format like.)
- the app reports position server again if device's location changes, , gets new list of users.
- you can use google cloud messaging, or persistent connection, let server notify app when new users appear nearby, if application needs that.
- when user goes offline, app sends message server tell it. erases user's location database user won't show after has left area.
- the server should delete locations database if haven't been updated in amount of time, in case app crashed or got disconnected abruptly.
for server, can implement on top of postgis, example. postgis plugin postgresql allows answer spatial queries.
this specific need, don't think there's existing code can download you. once you've tried out, ask new question if stuck.
Comments
Post a Comment