in my android application i need to track user location online and offline mode ,for this i am storing user's location coordinations in server and at admin retrieving those coordinates to draw path , online mode working fine but whereas i am getting this problem in offline mode , offline mode gps providing coordinates drawing the wrong path , how can i solve it please guide me .
check this image
If it's working on the online mode, I would suggest the following:
Verify that the timestamps of the offline locations are correctly
saved and sent to your server. Use the getTime method on
android.location.Location instances to get the right time. Relevant
docs
In offline mode, the accuracy of the data collected can be
significantly affected, and you can evaluate whether the data collected
after verifying the previous point is accurate for your use-case.
Disclaimer: I work at HyperTrack and we build SDKs to get accurate location data and build live location features.
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.
First of all I would like to mention that this would be done with the consent of all users!
That being said, what I am trying to create is an application where the users would see their location and the location of all the other connected users (latitude and longitude).
I am pretty sure the best way to do that would be to send data to a server and then have each device retrieve that data but I would like to know if there exist other ways of doing this. Or perhaps someone could point me in the right direction on how to create such a system with a server retrieving and sending data to android devices ?
GPS coordinates will do for you. You can get the coordinates and save in server then all the coordinates of a particular device can be retrieved by any connected device.
We have Location and LocationManager in android which shall do the job for you. Read more about these in the Android Developers
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 am trying to develop an android program that finds the location of the nearest hospital WITHOUT using the internet. Instead, I want it to use a stored map on the android device. Is this feasible? If so, Can anyone refer me to the code?
I successfully developed a similar program that uses google API, meaning it will contact the server and use the internet. I reused the source code in this link.
But in some cases, my user might not have an access to the internet and it is urgent to find the nearest hospital. How can I solve this issue?
Another much simpler solution is to store the coordinates of each hospital in a file.
At App start your read the file in.
Possible file format:
Hospital Name, latitude, longitude, Adress Optional
Then simple calculate the line of sight distance to all hospitals using CLLocation distanceTo(). Then sort by distance.
Take the shortest.
Although this is not road distance, it will work as long as there is no river or rail road inbetween
It's definitely possible.
You'll need to use offline map data - you can get map data from the OpenStreetMap project. I'd recommend letting the user choose which areas to download after initial app installation, and then the data will always be available.
Later on, usage of the location API does not require internet connection. You'll get co-ordinates, with which you can calculate the distance to other co-ordinates (of hospitals..).
Obviously, your challenge will be to create a hard-coded list of hospital locations (albeit update-able, make sure the app can download a new list when internet is present, for example download a XML file).
I have read many q and a's about this subject, but not quite what I am asking. Is there a way to store the cell-id to latitude - longitude database for the local area only, like the google maps new offline feature, could you get the localized information and store it, to cover the same ground as the map?, I am looking to make an android app which works offline, which is power efficient, and this is the best option that I have thought of. I have checked opencellid, and the kml file it provides, would that be enough to find the location without an internet connection or gps?
You could explore the offline database option provided by LocationAPI.org to use for your app. Storing 36 million+ cells offline would be a task though!