Android How to track other users' current location Parse.com - android

I'm making an android App which has a function of showing users' current location on Google Map.
I got trouble on tracking the users' locations and placing those locations on a map. I could get A user's current location and place it on the map, But have NO Idea how to do this for all the users' locations on the same time.
I was thinking that I first send all the users' locations to the Parse.com and get them back and show them in a map, But I think this doesn't make sense because that is too much of work, In other words, I can't upload so many users' information on the same time (like per every second).
Is there any other way to solve this problem?
Any tips Please!

https://www.dropbox.com/s/b4h2to1cdbx087b/SAmpleApp.zip?dl=0 try this i have done similar few weeks back whole src code is in it,you might are gonna need few libraries to run it, using same hope this will help.

This is what you need :
parse any wall sample project This projects included the code on how to solve your problem without any other libraries. It will sync with the database while you move within the app. so great because user will not even know it's syncing in the background. I have tested this so it takes about 2-5 seconds to update the map after you add a new location to the parse backend.

Related

Can I fetch the data being given to an app by its host and store it locally?

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.

What's the best way to update a GoogleMap map with markers that come from the server?

I'm currntly working on a project that uses Google Maps API for Android. In my MapActivity, I have to distribute all the marker that are in the polygon for the current visible area. My problem is, to get the coordinates from the server, I run a new thread with AsyncTask everytime the user moves the camera, but as it runs off the UI thread, when I get the result from AsyncTask using MyTask.execute(params).get();, my map gets really lagged and slow and eventually crashes my app. So, what's the best way to do what I want without crashing the app?
Thanks in advance!
The Too Many Markers! article would greatly help you with your concern. You can check out the Viewport Marker Management section of the article. Basically its just showing the Markers that are in the user's current viewable area. As the user pans/zooms it subsequent request to the server to retrieve new markers, other markers that are not in view are removed.

What logic is involved when comparing a location to multiple users

Using Android Studio, what sort of things are needed when trying to compare a specific user's location to every other user. For example if there are 1000 simultaneous users, and I want to find the closest one(or farthest) to any given user, what sort of calculations need to be done?
If each user's locations were saved to a DB, where do I start? Is it necessary to compare one location against the 1000 (or more) users to find the closest, or would it make more sense to make some type of cut-off (i.e. only compare users who are within 50km).
It seems overwhelming and I am new to android, so I am unsure where to even start. Parse.com and Pubnub are being used in this project.
Geohashing by User Proximity Tutorial
I'll reference for you here the geohashing tutorial that walks you through how to build a realtime app that connects users based on relative location.
Note that this example is written in JavaScript and not Java/Android. However you can still use this design pattern to determine proximity.
App Geo Location: https://www.pubnub.com/blog/2014-05-07-geohashing-chat-by-proximity/
There is also a short video which discusses the Geohasing concept.
Adding in Parse SDK and Location Comparison
Also you can add in this link: Parse reference guide. And a Parse Connector SDK if needed.

Tracking a users position and showing it on the map for all other users - Android

I was searching for hours, but I can't find an answer on this topic. I have managed to set up an application which shows my position, tracks it and updates my marker whenever my position changes.
I would like to do the same for all other users (for finding friends), but I don't understand the right way this has to be done.
Should I upload each users Lat and Lng to a server, then downloading it while placing markers on the map? This way I may not get fast location updates, or does the Google Map Api contain some tools to achieve this in the right way?
I would really appreciate some help.
E.
UPDATE
After doing some more resources, I realised that an online database is the way to go for this task.
Steps I made to read save and retrieve users positions:
Create an online (mysql) database
in my android project I have implemented: GooglePlayServicesClient.ConnectionCallbacks,GooglePlayServicesClient.OnConnectionFailedListener. But most important is LocationListener - to receive the current location coordinates each time the user changes position.
I then uploaded the coordinates using the HttpUrlConnection via POST method, and adding them to the database using php.
back in the app I create a new instance of the GoogleMap class, and the same way as I have uploaded I download all other users coordinates via HttpUrlConnection, iterate over the JSON response and placing markers on the map in the same time.
Everything works like it should, there may be other ways but I think this is the most straight forward solution. Hope this small guide will help.

Users of an application on a map

I have seen some applications that display on a map the users who have the application in use or installed.
I'd like to implement something like this in my project, the problem is I do not know where to start ..
anyone know any reference I can read?
This is an image to try to explain what I want
Thanks in advance
Regards
When user installs app, get its location using GPS, send it to your Server save it there.
When you want to show map, get all locations saved on server and display it on map.
You can update user location each time application is launched, updated it on server as well.

Categories

Resources