I'm developing an android app using android studio. Basically, a user will take a picture of a landmark in the middle of nowhere, and walk to a road. During their walk, their location is recorded in a list every 5 seconds and once they reach a road, all of the recorded waypoints are sent to a database so other users can see how they got there.
The issue I'm having is that it isn't plausible for them to walk with their phones open, as they could be going on a difficult hike. What I want, is for their location to still be added to an array while the phone is in sleep mode.
I tried using an alarmManager but after I got it all figured out, I was informed that the minimum time between intervals is now set to 60,000 milliseconds which doesn't work at all because they will get very far after 60 seconds.
I also tried using wakelock but it didn't seem to work. A this point, I'm not even sure if this is possible, but I'm sure there is some sort of alternative. Any advice would be great at this point!
Related
I am developing an App, a simple, but hopefully addictive little game. The user has to solve predefined levels, as quick as possible.
Information on the levels is stored online in an MySQL database, which also contains the average time it took all players to complete a given level. Also, the level-data is stored, locally, in a SQlite database on the phone.
What I want to do is the following. I want to synchronize the average time (from server to phone) and upload the time it took a player to complete a leve (from phone to server).
Ideally this happens each time the player starts the app or finishes a level. For this, I am considering a Firebase Jobdispatcher, but I was wondering if this is overkill or not. For your information: it is not the end of the world if the average time stored on the phone is not entirely up to date. The game will work just fine without it being up to date. On the other hand, I want it to get updated regularly as the performance of the user will be compared to the average time.
I am a beginner, who wants to do things correctly. Hope you can help.
It sounds like you already know when some work should happen. As you said:
Ideally this happens each time the player starts the app or finishes a level.
You don't need JobDispatcher to schedule work when you are already in control of the times when the work should happen. JobDispatcher is used when you need to schedule some work at some point in time or interval when your app may not even be running.
I was wondering if there is a way for me to detect if the users device is being "obstructed" by a building or roof of some sort. Im developing a very precise location based app and its KEY that my users get alerted if something is wrong with there GPS or something is getting in the way. Physical object.
EDIT: The app ive created strictly takes snapshots too its not something thats constantly going. Just a quick snapshot.
Not directly. You can try calling LocationManager.getGpsStatus and iterating over the list of satelites every so often and looking for a jump in signal to noise ratio since the last reading. Getting a working algorithm is going to take a good amount of work and testing on a variety of devices with different GPS chips.
My application keeps track of a user's location, and sets up proximity alerts for nearby stores returned by an API for an automatic-chickin type functionality. I'm hitting my head against the wall trying to figure out how to improve the accuracy when the proximity alert is triggered by network location. I need some way to confirm that the user is at the location by either checking again within a few minutes, or by confirming their current position via GPS.
Part of the issue is that the Context handling the proximity alert is an intent service, so anything that works asynchronously causes issues when the alerts fire in rapid succession. Clearly there's a way to do this properly (e.g. Google+ checkin notifications), but I'm at a loss as to where to look next.
My experience is that network location is often less accurate than GPS location, although neither is 100% reliable. Sometimes GPS will be perfect, but at other times it's wrong my maybe 50 metres or more. To handle the this, I think the best way is to combine the two location sources using a simple Kalman filter, so that neither network or GPS trigger promimity alerts directly, instead it's the result of the Kalman filtering that is used. See my answer to Smooth GPS data for full details of a Kalman filter that might work.
I would like to implement GPS Tracking service. After a search on the web I'm still a bit confused on the best way to practice this feature.
I want to start following the user when he gets a mile away from his home.
I thought that the app will be installed at user's home and using:
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
I'll get the user's coordinates and compare it with changing coordinates as he travels.
When the user gets away a mile from his home I'll send SMS messages with his maps location every predefined time interval.
I was wondering if there is someone who done something similar before and can recommend a best practice for this task.
Also, how accurate the GPS can be, and what might be the best practice to get distance?
Thanks in advance.
From my experience it is not a good idea to use GPS all the time to track when a user departs from his home location because it burns the battery in no time. I ended up learning the home location by looking at the cell tower IDs over night (assuming the user is at home then). If you reach a certain level of confidence that you know the user's home location you can ask him something like "Are you at home right now?" to be completely sure (although this is somehow creepy for many users).
If you follow this strategy you can start the GPS if the user connects to a new cell tower and save a lot of battery.
Regarding accuracy. You can get the accuracy provided with each Android.Location object. If you are outside, this is usually 5 or 10 meters. But be aware that there is only an 68% chance this value is correct, according to the documentation:
We define accuracy as the radius of 68% confidence. In other words, if you draw a circle centered at this location's latitude and longitude, and with a radius equal to the accuracy, then there is a 68% probability that the true location is inside the circle.
Be carefull, the getLastKnownLocation method will not necessary return the user home position.
You shoud rather get the current position. Most of the time, getLastKnownLocation is used to get a location quickly (avoiding heavy background work).
GPS accuracy depends on many factors:
Weather, quality of the chip, field, ...
But, most of the time, it's more accurate that the network provider.
Here a very good link : http://developer.android.com/guide/topics/location/strategies.html
You will learn a lot with that.
My applcation description:
The application will generate the user location everywhere and everyime 24/7.
The other app which browse the locations of the user will show him the locations with 1-10 minute spaces(I havn't decided yet) and of course that the location record that will be printed will be the most accurate.
I have tried diffrent type of things but I can't get the most accurate location for a minute for example.
Many suggested to send to the requestLocationUpdate a minute as a parameter but then it will generate every minute a location but I want to get the most accurate location in that minute so I guess I will have too generate all of that minute locations and choose the most accurate.
I came across many errors such as getting a city level location which is pretty bad(You have been in xx:xx at new york city.. I'm not looking for that).
There are many considerations such as battery safe and accuracy.
I'm agree to compromise about the amount of locations (means print every 10 minute the user location instead of 1 minute).
Anyway I'm so confused, if someone got a plan (not code level) how to manage that system I would like to hear.
The GPS location provider should give you precision of meters if you are in open air. If you take samples every minute with requestLocationUpdate, that should be enough.
It is not possible to "get N samples in a given time interval and keep only the most accurate one", you should do that calculation keeping a buffer of positions if you need that. In any case, I don't think it is worth the effort in this kind of applications.
The battery life is going to be a problem if you want a mobile device to last more than 4-6 hours with the GPS + internet connection active.