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
Related
I am working on ride hailing app. I am getting location in the background after every few seconds. To get location, I am using Foreground Service. It is working fine.
But on some devices, there are different types of options to control the Background power consumption. If these options are enabled then these devices will freeze/terminate may app and foreground service too.
Due to which My app will not update the location.
Is there any solution to get location or not in this case?
For further details. please have a look on this link
FurtherMore, my second question is that if I will use Google SDK for this purpose, will google handle this or not?
If I use google sdk then will google sdk be responsible to get location in each scenario or not?
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 would like to know if it is possible to clear the "location" that is stored by play service's fused location API. When testing my app on a real device, I would like to recreate few scenarios and that's the reason I would like to know if this is possible.
I tried to clear "Google Play Services" cache and data. But, it does not seem to help me. Location still seems to be cached somewhere.
I just disabled the GPS then restarted the Android phone & I found that the locationManager.getLastKnownLocation returned NULL for location.
Google Play Services is central service and serves every app installed on your device. After clearing cache and data, if any app connects with Google Play services on that device(which almost every Google app do), then Fused location api will fetch and save location for that app. After that once your app fetches last known location in onConnected, it will return the location.
It is hard to simulate the scenario your are trying to achieve unless you hard code the values to be blank.
Just turn the location off and then turn it on again. It will clear the last known location as it clears all the cached location data on the device.
I am working with the Geofence API Sample application I've got it running and seems to work alright. I did make the modifications to it to use BroadcastReceiver instead of the IntentService.
But I will only get the notifications if I have some other app open that is using GPS such as Maps, or GPS Tester app.
If I don't have one of those apps open and I walk into the geofence zone nothing happens. But as soon as I launch one of them I will get the notification within a few seconds.
I ended up creating a service that forces the GPS to stay active by requesting location updates on a relatively quick interval.
While this is admittedly a poor work around for a "real" application. It worked for my purposes. In which I needed to be able to present a working proof of concept to an audience, which impeded my ability to use a geo points which were further spread out.
Even I too had a struggle with getting Geofence notification as soon I entered Geofence or Exit the one.There were always delays in notifications until I found a really nice Location Library called little-fluffy-location-library which serves my purpose.Location updates will be broadcast to your app periodically.
According the Documentation it says that:
The library works by using Froyo's passive location listener (only possible with Android 2.2 and up, hence why it works best with it), which listens to location updates requested by other apps on your phone. The most accurate location is broadcast to your app approximately every 15 minutes. If a location update hasn't been received from another app for an hour, the library forces a location update of its own.
I think you should give a try with this Library and Let me know if it works for you!!
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.