Android Location services - android

I need to create a database of gps coordinates by walking some trails and periodically storing coordinates. What would be the best way to get gps coordinates quickly sent and stored on the phone in an array of some sort so I could later access the coordinates. I need to be able to save them on the phone and then get them back to the computer. Any tips will be helpful. thank you

Here's a great page on acquiring location and I'd suggest you store the locations received in a Sqlite database, which means the location data will persist between each time you run the app, which seems like what you need.
As each location comes in, you can store them in the database, and from there it's easy to handle them, e.g. pass them on. Not sure what you mean by "get them back to the computer, as you don't say why or in what format.

Related

Discarding a message, before it gets displayed to the user?

Im trying to develop an Android messenger application where a message is sent by user 1 to everyone using the app, the message contains the GPS location of user 1. Is it possible to determine the distance between user 1 and the user 2 and based on that either choose to display or discard the message. How do I go about it? Cloud you point out considerations that I might have missed out?
Another method I believe is possible is to periodically update a server with every users GPS location and then let the server decide who gets the message, but I would not like to use this method as it would be a privacy issue. No one would want their whereabouts being tracked by a server all day. Is there another solution to this?
You can use the haversine formula to determine the distance between two locations. Here is a link that provides the formula in various languages.
http://www.movable-type.co.uk/scripts/latlong.html
One way of doing this is to store the most recent location of a phone on the server in the database. You can then query the database (using a stored procedure) to determine who your closest neighbors (phones) are by setting a radius. For instance, show me all the phones within 500 meters.
Here is an example of how to do this:
http://www.movable-type.co.uk/scripts/latlong-db.html

Best way to send user location updates to the server in the background(Android)

My app needs to send the user location update frequently even when he is not using the app. So I created a service that returns start_sticky and I am using Google location services to send the data as specified here
android location updates. My service is implementing ConnectionCallbacks, OnConnectionFailedListener, LocationListener So whenever onLocationChanged(Location location) is being called I am sending the location to server. I want to know if doing this way can cause faster battery drain. If so what is the better way to do. While asking this question stackoverflow gave me a warning saying that the question appears subjective amd might be closed. But I cant figure out another way to ask this question. Hope someone might help me with this. Thanks in advance
I can think of 2 methods for it:
1- I assume when the location of the user has changed, the app sends the server the lat and lng. So, you can save the lat and lng changes and send a group of them to the server every 20 lat/lng have been collected.
2- You can check if the lat/lng of the location update varies greatly from the previous ones and accordingly you can determine the rate of which you send the data to the server. For example, if the lat/lng are approximately the same, then lower the onLocationChange Listener rate (for instance the user is at home). And when the changes are great, then increase the location listener rate (for instance the user is driving).
However, this all depends on what the data of location is being used for. Hope this helps!

Best Practice to Save GPS Coordinates

I'm developing my first android app and one of the features is tracking the user's route. At another point in the app I'm going to have a review and bring up another map to plot the locations. I implemented the LocationListener and set the minDistance to 50 meter and everything is working correctly. In the onLocationChange I add the new location to a list. I'm wondering what, in your opinion, is the best way to save this list? Currently I'm just writing the list to the local SQLite db, but I'm wondering if this best or if there are other alternatives I should explore.
Thanks

Notify when user is in my location in Android

I am looking for an easy way to check if a user is at my location (50m) radius if notify me.
Right now I have a service running every two minutes getting position of each user comparing it and then notifying if user in same location.
Can this be done using promixityalert: http://goo.gl/9I857T?
Thanks!
Instead ProximityAlert I would use Geofences.
http://developer.android.com/training/location/geofencing.html
Is newer and does a more effective use of the battery
In your case, you can have a service that sends to the other device the current location every X minutes, so it can update the Geofence. The problem that I see is that there would be a lot of calls, spending battery and the data plan.
A good approach is to use the Location Services API, you can detect if a user is standing or moving.
http://developer.android.com/training/location/activity-recognition.html
Using this and sending new locations only when the user is moving you will be able to reduce the amount of calls.
Parse is another option as #thepace mention. It is easy to use and whit it would be easy to implement what you are trying to do, but is not free :(
Hope it helps.
Issue: Check if any user (multiple and variable location) is within specific radius of my current location(variable).
Solution:
1. Parse.com
a) Ensure every user has their location updated in Parse DB including yours.
https://parse.com/tutorials/anywall-android
b) Use push notificaitons: https://parse.com/docs/push_guide#setup/Android
1> Create a channel wherein only you are subscribed.
2> Create your installation query and send notification to it to the channel subscribed.

How to determine which persons are close to you from a database

Let's say we have a few 100.000 people and they all share their location.
Their location is stored in a database online as Geopoint.
If I open an app on my device and I only want to show the let's say 50 closest people, what would be the way to approach this.
I know I can just retrieve every bodies location from that database and check the distance for every single device. But that seems to be not a very effective way. Especially if it would become millions of people.
What is the proper way to approach this?

Categories

Resources