How apps are getting locations when Background Restrictions are turned on? - android

Some android devices have options to restrict apps in the background to save battery consumption. If I will turn on this option, my app and its background service will be killed. Some apps like Uber, Careem etc are using google services to get location of driver, to track driver.
I tested Uber Driver app, I turned on this option, and then killed the Uber Driver app. Location of driver was not updating, from pickup to drop off, location of driver was not updated. When I opened the driver's app to end the ride, location of driver updated, and whole distance was calculated accurately.
My question is this, if app is restricted to be used and killed, then on opening app, from where it gets all the locations, how Uber app knows the travelled distance?
Please have a look on attached images, devices have options like these:

Related

Android - Appium's mocked location will be overwritten by Wi-Fi, Bluetooth and mobile networks

Within my Appium tests for an Android app I am using Appium's setLocation() of AndroidDriver to mock a location. This works properly, but since the app is requiring "High Accuracy" as location method the mocked location will be overwritten after a few seconds by the location which is generated by Wi-Fi, Bluetooth and mobile networks.
Is there any solution or workaround for this kind of issue? I want to set the location permantly (for the whole duration of the test), but can't change that the app is forcing the user to enable "High accuracy" mode.
Btw: I'm testing on a lot of different real devices and not on emulators.
First enable developer option in your phone.
Go to your phone Settings > About > Tap Rapidly on Build Number until it says “You are now a developer.”
Then go into your Developer Setting and check Allow mock locations.
Now you need to Download App that will allow you to fake the GPS location. There are several different apps that can do this. You can find free app in play store.
Finally you can select a random spot somewhere in the world and activate the fake location using the app.

Run own app on an Android device that mocks GPS location

Is there a reliable way to mock GPS location on an Android device (rather than emulator)? I know there are several ways how to do it in the emulator, but I'd like to run my app on the device. I am not interested in existing apps like "Fake GPS location" etc., I want to get my hands dirty by logging actual GPS data and then "playing" it back with various adjustments, so I need to write my own code.
I see on my Android 7.0 device that there is a setting "Select mock location app" under the Developer options in Settings. Strangely, it lets me to select Samsung "Messages" app as the mocker app, I can't imagine why and how exactly this app would do the location mocking. Anyway, it seems that if I learn how to manifest in my code that I want to mock GPS location, my app would hopefully appear in this list available for selection.
I read that things have changed in this area over years, so online references might not be up-to-date and bring more confusion than help.

Javascript geolocation - GPS settings - FINE vs COARSE

I am creating a geolocation app with Intel XDK (iPhone and Android) and have 2 questions:
How can I display the geolocation settings of the device if the GPS is not active on the phone?
How do I know if the latitude and longitude values returned are from the GPS or from the wifi/data coords? I figured that wifi/data returns a short value (eg: 43.475748) and GPS returns a longer value (eg: 43.47573849384) Am I correct in thinking this?
1.) Most devices will cache the last known geo location. Unfortunately, this behavior is not consistent, and there's not much you can do to change that other than attempt to remember a set of last known locations within your app.
2.) I don't think the HTML5 geo API provides that level of detail, but you could look at the accuracy information that is provided. The designation of "fine" versus "coarse" is somewhat arbritraty, since it means different things on different devices and operating systems (the nature of cross-platform applications). I would use the accuracy feedback as a relative guide.
If you want to play with the geo location feature, checkout the "hello-cordova" sample app in the XDK, it is very easy to use to see how the geo feature works on a variety of devices. You can use it in App Preview or simply build the app and install it on a variety of devices. Note that if you first push the "fine" button then the "watch" button will retrieve "fine" results. If you push the "coarse" button before pushing the "watch" button the watch results will be based on a "coarse" setting.
In general, it is best to first request a "coarse" reading (with a short timeout) to get a general location (or a cached location) and then switch to a "fine" request if you need a more precise location. Battery life will be better if you stick to infrequent "coarse" readings, especially if you only need to know the general location of your user (for example, in which town or neighborhood are they located).

Android show android natice pop up settings/cancel to enable location service

I am working on an android application that uses geo location services, when the user accesses such service if location access is disabled on the device i want to call android native pop up that guides user to enabled location access. Is it possible to do this ?
I noticed there's even better way to achieve good location settings, without "guiding" user to turn them on, mentioned in this question:
Enabling Location with mode High Accuracy or Battery saving without user needing to visit Settings
Since Google Play Services 7.0 you can ask system to offer user turning the settings on with one touch. It's how Google Maps are doing it.

why do apps show a GPS start button?

If you look at apps such as Google Maps app on Android, it display a gps icon, that when clicked starts the gps. However, if I don't click that image, and I move, it tracks me anyway. So what is the purpose of they button which we see in so many apps? Does the phone rely on GPS only when that button is pressed, or do they use the button, because they start the gps every x minutes, so if you click the button, it start it immediately?
?
The GPS radio is not started automatically.
When the GPS is off, the phone uses nearby WiFi nodes to find the location. That works pretty well in areas where there are a lot of known WiFi nodes, but the GPS is more exact, and works pretty much everywhere.
Applications like google maps have the gps logo because you may want to be shown your location, usually the application will try and find your location based on wifi and networks first and then using gps. The button will tell the app you want to know the location then and there and that's why it starts, other then that it should just do it automatically.
GPS isn't the only way to track a phone. When you don't have GPS enabled (or if your phone doesn't have a GPS chip in it), the cell phone can triangulate it's distance from the nearby cell towers. It can also do the same thing with nearby WiFi networks.
Since GPS takes up so much power, apps will ask you to enable GPS yourself instead of automatically enabling it when the app starts/runs in the background.
You can read more about common phone tracking methods here: http://en.wikipedia.org/wiki/Mobile_phone_tracking

Categories

Resources