pressing Home键后的And​​r​​oid服务运行Home、pressing、oid、And

由网友(吐彩虹症)分享简介:我有一个Android服务,使用StartService在OnCreate中创建的应用程序的第一个活动的()。我需要整个应用程序的寿命是运行该服务例如,所有的活动中的应用。但该服务不应该在pssed用户$ P $ HOME键或返回按钮所消耗的资源。有没有优雅的方式来做到这一点以外的其他的onPause停止所有活动的se...

我有一个Android服务,使用StartService在OnCreate中创建的应用程序的第一个活动的()。我需要整个应用程序的寿命是运行该服务例如,所有的活动中的应用。但该服务不应该在pssed用户$ P $ HOME键或返回按钮所消耗的资源。有没有优雅的方式来做到这一点以外的其他的onPause停止所有活动的service()方法?

I have an Android service, created in OnCreate of first Activity of the application using StartService(). I need this service to be running throughout the life span of the application ie, all the activities in the application. But the service should not consume the resources after user pressed Home key or Back button. Is there any elegant way to do that other than stopping the service in onPause() method of all the activities?

推荐答案

您可以做什么达雷尔建议,但摆在扩展活动一类新的code,然后扩展了你的所有正常活动。

You could do what Darrell suggests but put that code in a new class that extends Activity and then extend that on all your normal Activities.

我不知道实现自己的目标的任何其他的更优雅的方式。

I don't know any other more elegant way of achieving your goals.

阅读全文

相关推荐

最新文章