I have followed this tutorial about how to use the proximity alert and how to register it.
It all works but when I close the app (with the back button, not the home-button) then the proximity alert does not work anymore. Does anyone know how to set it so that it runs in the background?
Thanks in advance!
It seems that you can not get location updates when your application is not running. Receiving location updates in the background is not a good idea since it drains battery power and the user might not be aware that the location is being tracked since the normal behavior for pressing the back button on the application is for it to close all services. If I want my application to continue running in the background, I as a user would press the home button.
Look at the model used by the "My Tracks" application.
Also see the documentation from Android on locations and usage models:
http://developer.android.com/guide/topics/location/obtaining-user-location.html
If you have informed yourself about the reasons not to have the application do this in the background but still want to run this in the background, look into Services
http://developer.android.com/reference/android/app/Service.html
They can run in the background and provide your application with data when asked.
Fundamental part of Android... Services.
http://developer.android.com/guide/topics/fundamentals/services.html
You should get it if you register for it, but keep in mind that proximity alert may not be immediate if your screen is off. If your screen is off, then location is probed for every 4 minutes as stated in the documentation.
Related
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 wondering if you can launch a given Instant App based on the user's location. Is this kind of thing possible? I suppose it would require some kind of server to be always running on the device.
Edit: To clarify a bit, this would be like if App A has a service that tracks the user's location and if they go to a certain spot it would launch Instant App B.
Thanks!
it would need a constant running service and launching the app might be a problem since this particular function could be ransomware like but a notification could be instead that's.
beside that it would a continuous location request at all time.
Here is the thing, I am not used to the latest android yet and the new system is giving me some confusions. Usually, for the older androids, if I close all background apps, I won't get new notifications from them. But after switching to a new phone with the latest android, I realized that even if I do close all background apps, I still keep getting notifications from them. So, how are the apps still pushing notifications if I already close them from background?
(Say google maps for example, I am 100% sure I killed it in background but now it keeps notifies me about my live traffic status on my notification bar.)
So Here's the answer-
Yes, they are. Whenever the Internet is turned on or you get a message, listener of that app wakes up and check for any notification and if there is something new, it shows you the notification.
These apps keep running in the background if not put in sleep mode by your phone and use the resources.
Like you don't want to get notified by WhatsApp for a new message but the moment you change the network, unlock your phone again or turn the data on, an event listener will wake up and notify you of new messages.
Also, wake timers are used to notify you after some fixed time like after every 5 minutes.
This is the thing I hate the most.
Not promoting but here's the app - search play store for Shutapp - Real battery saver (Blocked from Play store a while ago and doesn't work anymore for "obvious" reasons). It will turn off all the background apps and you'll be amazed to see a long list on first use.
This will remove all the apps from background until you open them again. I use this app most of the time and it really works great.
Try this out.
I am new to Android and have a problem with the Notifications. I know that this topic has been taken up earlier as well but I just wanted to know if there is any other way to go about it.
Problem : In my application I want that the user is notified that he/she has entered in the radius of a particular location. I have the functionality working when the application is alive and in the foreground. I will however want that the user is also notified when the application is not working and not there in the foreground.
In the previous posts I have found out that this can be done by using something called as the C2DM. Altough I am not much aware of it but by using C2DM I would be introducing an extra network trip. My question is that the only way to go about it? Can't this functionality be done any other way round, something locally like something of a daemon thread of sorts?
Also if C2DM is only the way, and as my application is not in my foreground will the C2DM also inform once the user reaches the radius of a particular location?
Will like to thank you all in advance. Please do let me know if any one of you have faced a situation/problem/requirement similar to this before and also if you can highlight the way forward for this?
I have the functionality working when the application is alive and in the foreground. I will however want that the user is also notified when the application is not working and not there in the foreground.
Use addProximityAlert() on LocationManager, and then it will not matter whether your app is in the foreground or not.
I was reading Reto Meier's (very useful) Android developer blog post A Deep Dive into Location when I read the following sentence concerning use use of the PassiveProvider and PendingIntents to help maintain a "fresh" application:
"If your app recognizes the concept of “exiting” (typically when the user clicks the back button on your home screen), it’s good form to turn off passive location updates - including disabling your passive manifest Receiver."
While I understand the need for apps to be "good citizens" in the Android community, doesn't this also defeat the purpose of using the PassiveProvider and PendingIntents to help ensure location freshness? From what I understand, turning off the passive location updates will prevent my app from receiving those updates. If this is the case, then when the user re-launches my app, wont they have to wait for another location fix? I know that I can call getLastLocation(), but I was just wondering how the PassiveProvider and PendingIntents help to ensure freshness when you explicitly turn them off when the app exits.
Well, I guess the answer is not so obvious :
there is no real way to close an application in android (for the user I mean). But the blog seems to assume that hitting the back button while in the main app screen/activity actually means to exit the app. This is, for instance, the way dolphin reacts to a back button hit.
So if people use this button, you can assume they want to quit your app and you can just close every resource you used, including passive location providers & receivers.
But, mostly, people will just hit the menu button and switch from an app to the other this way and let them all open. In this case, let your receivers in place so that your app keeps fresh as explained by Reto in his post.
Update : it looks like an official good practice to use back button this way (close app), this blog is quite interesting about it : http://www.androiduipatterns.com/2011/03/back-button-behavior.html.
Regards,
Stéphane