i am currently developing an app that requires location from the start. I have a method that checks if location updates are up, but even when GPS is turned up I cant ensure a Location Update when the app starts. How can I ensure a fresh location update when my app starts?
i am currently developing an app that requires location from the start.
That is a design flaw in your app. Please redesign your app to take into account that:
the user may have GPS disabled, or
the user may not have used GPS recently, so it will take some time to acquire a fix, or
the user may not be in a location where GPS signals are available (e.g., inside a large building)
How can I ensure a fresh location update when my app starts?
You can't.
Related
Google documentation states:
If you request foreground
location and background location
at the same time, the system throws an exception.
Now, suppose I want my app to be able to access location when (i) the device is locked (ii) the device is unlocked and the app is in foreground. Is it possible in this scenario?
According to the documentation page here:
Even if several features in your app require location access, it's
likely that only some of them require background location access.
Therefore, it's recommended that your app performs incremental
requests for location permissions, asking for foreground location
access and then background location access. By performing incremental
requests, you give users more control and transparency because they
can better understand which features in your app need background
location access.
The process for performing incremental requests is as follows:
At first, your app should guide users to the features that require
foreground location access, such as the "share location" feature in
Figure 1 or the "show current location" feature in Figure 2.
It's recommended that you disable user access to features that require
background location access until your app has foreground location
access.
At a later time, when the user explores functionality that requires
background location access, you can request background location
access.
So the short answer is yes. You can use both foreground and background locations in the app, just don't ask for both at the same time.
I want to get location update few times an hour from android device.
I think the following paragraph implies I can achieve what I want..
https://developer.android.com/about/versions/oreo/background-location-limits#tuning-behavior
Consider whether your app's use cases for running in the background
cannot succeed at all if your app receives infrequent location
updates. If this is the case, you can retrieve location updates more
frequently by performing one of the following actions:
Bring your app to the foreground
I understand it as app can receive infrequent location updates without bring your app to the foreground (is my english bad ? :()
Google Map does track where you go without notifying you that "it is tracking you" when the map app is in the background , even when it's killed.
How can I achieve that ?
I've looked at
https://github.com/mauron85/react-native-background-geolocation.
https://github.com/transistorsoft/react-native-background-geolocation
and there seems to no way to not display the notification.
How can I achieve what google Map does?
tracking device location without showing the notification?
Is google having an unfair advantage at this?
I'm developing an IOS / Android gps based application that needs to update location always (or after significant location change). Similar to Life360 family locator app. This app doesn't need to start at all and yet when you open the app it has all your location data captured for a week. If I'm checking on my kids location and they don't have their phone actively running the app, I still get the real-time location and their gps history.
How is this accomplished? It seems that the app is logging gps data, not only when in foreground and background but when not running at all. Is there a special run-mode these apps use?
thanks all!
Mike
I can only speak for iOS.
On iOS you can register for significant location changes, and your app will get notified in the background when a location change event occurs (and even get launched in the background if it had been terminated). You can then request background time and transmit your updated location information to your server.
I am able to get the user location by using Google API and Location services. That location is then saved to an online database. However, how would I go about making the location update every X amount of time (lets say 10 minutes). Also, the Google API and location services is linked specific activity. How would I make the location services available to all activities, meaning that once the user is logged in, no matter what activity the user is in, the location would be updated and saved to my database? Finally, if the phone is in sleep mode or the app is running in the background, would the location still be updated?
Thanks, any suggestions or pointers are appreciated!
It is a duplicate question.
There are many solutions.
I recommend to you read following question.
Example: Communication between Activity and Service using Messaging
I am writing a program in Android that uses GPS. It will prompt the user to turn on location services if it is not on (which I guess is equivalent to turning on gps ?). My question is: does the gps immediately start consuming extra battery power as soon as location services is turned on or it uses batter power whenever the location services is queried/used for a new location ?
The GPS starts working only when the location manager requests an update from it. Turning on the GPS in the device only allows programs to request locations if they want, but it doesn't mean the GPS is kicking in.
You can test it yourself: The GPS icon in the notification bar tells the GPS status. You can turn on the GPS, but the icon won't appear. Why? No application requests updates now. As soon as an application requests an update, the icon starts blinking (The GPS is initializing itself) and when it stops, it means the GPS is initialized and is currently receiveng updates.
The GPS consumes battery only when this icon appears.
My company wrote a blog post on this subject a while back. Check to see if its useful.
http://www.littleeye.co/blog/2013/03/29/understanding-gps-resource-usage/
But we missed talking about what happens when no app is actually requesting for a location update. And yes, as mentioned unless apps actually ask for a location update, they will not cause power drain. But note that even a single request for a location update (depending on coarse or fine grained request) can have unintended effects, as the device has to go thro various states before it can get back to its steady state.
Turning on location services is just permission given by user to applications for using location services. As long as any application not asks for location, power consumption is the same as with location sesrvices turnded on.
On the other hand - there is many applications trying to get location. Facebook, Camera, Android, many of ads libs, so yes - user can get battery life issues when GPS is unlocked.