开发者

Using PassiveProvider and PendingIntents to ensure app location "freshness"

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 hav开发者_JAVA技巧e 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜