When my app is triggered, it takes the current position of the user through the GPS (this function already implemented).
My question is: I want to know for example if I have users who are using my app in a given radius (1km for example). Is it possible?
Yes, but you need a server as well. Broadly speaking, the process is as follows:
The app gets the location from Android.
The app queries the server, sending the current location in its request.
The server stores the location and the user name in a spatial database; that is, a database of users that can be indexed by location. It overwrites the previous location if there was one. The server should also store the time the location was set.
The server also looks up the location in the spatial database to find all the users in the given radius, or the nearest n users. It sends the list of users back to the app. It might use JSON, XML, or some other format to send these data. (Since you control both the server and the app, you can choose whatever format you like.)
The app reports its position to the server again if the device's location changes, and gets a new list of users.
You can also use Google Cloud Messaging, or a persistent connection, to let the server notify the app when new users appear nearby, if your application needs that.
When the user goes offline, the app sends another message to the server to tell it. This erases the user's location for the database so this user won't show up after he has left the area.
The server should also delete locations from the database if they haven't been updated in a certain amount of time, in case the app crashed or got disconnected abruptly.
For the server, you can implement something on top of PostGIS, for example. PostGIS is a plugin for PostgreSQL that allows it to answer spatial queries.
This is a very specific need, so I don't think there's any existing code you can download to do this for you. Once you've tried it out, ask a new question if you get stuck.
Related
I would like to preface my query by saying that I am an absolute beginner when it comes to programming but I really want to realise this project so every little help is deeply appreciated.
I am trying to build an app that needs accurate train data for it to work and from my current research as there is not central government API for railway data , the only accurate data source for train location that I can find is in an other app that uses crowd sourcing to pinpoint the location.
I wanted to know if it is possible to fetch that train data from that app and then use it on my own as it would make my app a lot more reliable and accurate.
The issue currently is that the app only shows graphical representation of the data thats being fed to it from its servers , so I wanted to know if there is a way to access the actual data being sent to the app.
Thank you.
Let me clarify, this is a very broad question and hence will have a very broad answer too.
As far as I can understand from your question is that you want to show TRUE location on a map.
For this, you will have to understand the complete Tracking scenario. Let me explain it to you step-wise below:
There is an app, installed on a device (user) which fetches the GPS location (REAL) data and keeps sending it to a server (backend).
This GPS data is the Lattitude-Longitude coordinates of the device (user).
The server stores this information in their database for queries.
There is another user, different than the one currently sending the location data, who wants to know the location of the first user. The app which he is using will request the server (backend) to send the location data for the device. Which, in turn, will send the latest location data (LatLng coordinates) to the current app. This app will then show the location data over a map.
Now, usually, this process is followed to show one-to-one location data. However, in scenarios like Train Location etc, servers usually collect pool of location data, being received from several users, to cross-verify the actual location (average out, mean, location optimization algorithms etc.) and then display that information over a map.
As per your requirement, which I can understand, you want to get this REAL data directly from either another app or from the server. If you want to get the location data from the server, you will need an API, which serves as a Request-Response platform. However, if you are looking to get the data from another app, it would rather be simpler to get the location data directly, as your APP will also be installed on the device itself.
I would suggest you to kindly read about getting and processing location data, communication with servers over API etc for better understanding and implementation of your requirements.
I want to develop two apps which are related to each other. One is a postman app and another is for users who want to use postman's task.
I have been using node js server which uses socketio. I want to show couple of postmans in user app which they are in location constraint (define specific treshould). When the user taps his map and changes his position, postmans location should updated in user's map and show to them.
In order to design these apps, I had two scenarios in mind.
The first scenario I had, when user changes his position send his location to server and server should get postman's location which is in my defined treshold, but I think it's not optimal because when postmans move realtime in map, server should store their location and updated them and then fetch those to show in user app.
Second one is server broadcast to all postman's app and in postman's app side check treshould and if it's true send back his location to server.
Which of them would be appropriate to develop this situation?
Hi everyone I'm in trouble one of my friends asked for a chating Android app which it could find "People Nearby" using this app and first I said yes I can make it but now I'm unable to do.
so It's my very first app that I'm making it for someone I wanted to know if "People Nearby" is simple function for an app or it's complicated and hard to make it
I've seen this kind of apps like swarm that shows you people nearby
but unfortunately I can't find any help or source or tutorial for it the only thing I could find was Google's Nearby Messages which I'm not sure that's what I'm looking for
so I would be very happy if you could help me or at least tell me where I can find a help.
Server side:
(You can use python flask for this kind of simple requirement If you do not have experience in server side scripting)
Your API's must have.
/register -> Registering user profile (unique id, name, location etc) and save it in database.
/receive_location -> Receive location (lat lang values), update in the user profile and check with all records in your database who is in the radius(defined by you or get this as from user) and return the list of user details to client.
Client side:
Have an IntentService which will post location of the client to the server at certain intervals returns the list of users who are in the radius you define.
User googleApiClient to get the location and server .
http://developer.android.com/training/location/retrieve-current.html
Use recycler view to show this result. Send a local broadcast from intent service to tell the activity containing recycler view to update it.
Basic requirement for this is you must have server where all user data is stored.
You must have all users updated latitude and longitude.
To get updated latitude and longitude you must call your api at periodic times.
If you want nearby people search you must call api with your current latitude and longitude, then from server and your api must filter all users location and gives you nearby people.
I am working on an android application which can find users nearby.
I need help in design that application.
I am thinking:
1. When I start my application, I use API to find my location.
2. I send that location to my server.
3. server returns a list of other users nearby.
My question is how can the server keeps track of a list of users who are nearby?
Do I create a background service on phone who will report users location periodically?
And the server maintains a list of all users' location?
Is that approach feasible?
You're on the right track. If you are able to geocode or retrieve your current location lat/lon coordinates, there might be a library that can help you out.
My first thought was the Geocoder (https://github.com/alexreisner/geocoder) library for ruby, it offers a slick API that allows you to easily find other nearby objects:
if obj.geocoded?
obj.nearbys(30) # other objects within 30 miles
obj.distance_from([40.714,-100.234]) # distance from arbitrary point to object
obj.bearing_to("Paris, France") # direction from object to arbitrary point
end
There are other options that are easy enough too, if you're using PostgreSQL with PostGIS, you have some utility functions that I'm sure you could use to query 'nearby' users. (Found an example, "What is the best way to find all objects within a radius of another object?" http://postgis.net/docs/manual-1.3/ch03.html#id434832)
So the overall workflow would be:
Request lat/lon from device API
Send lat/lon to server/web service
Use library/database to find other users within a specified radius
Send list of users back down to device
I suspect the most difficult aspect would probably be keeping the lat/lon of other users up to date, but that's a different problem to solve.
Edit:
Just to clarify, you'll definitely want to store all the logged in users' lat/lon inside of some sort of database on the server. It's a very feasible approach, but you'll have to keep it up to date and be able to determine somehow if the data is stale (if that's important to your application). Whether you use a background service to keep that information up to date is kind of up to you and the constraints of the problem you're trying to solve.
I would like to implement a user count in a particular location on a map in HTML5. The HTML5 code would be implemented inside an Android application. Here are the steps what i have thought of:
Store the latitudes & longitudes of the location in a server side database.
Store a counter variable at server side database.
Users opens the Android application (current location calculated).
If current location is approx = to stored location then
=> XMLHttpRequest object sent to database server that stores the user's IP address and increments the counter
I have two issues. One is how to identify a user so that it is counted only once. IP address is not a very good way of doing that as it can be different for same user (user using Wifi and 3G). Second is to keep on updating the user list every 3-5 minutes
First I would recommend to use geofences (see http://developer.android.com/training/location/geofencing.html) for the location you want to track. That way you don't really need to handle the location yourself, but your app gets notified when a user enters (or leaves) the given area (location + radius).
To identify the user I'd suggest to create a UUID ( http://developer.android.com/reference/java/util/UUID.html#randomUUID() ), store it locally (e.g. in a SharedPreference ) and send it along with the location update...
I'm not sure about keeping the list up to date, since I'm not really familiar with ajax...