简体   繁体   English

在后台运行时,Android应用进入睡眠模式

[英]android app go to sleep mode when running on background

could my app does not use power and data when running on the background? 在后台运行时,我的应用程序可以不使用电源和数据吗?

my app is native app and i want my app does not need run when on the background. 我的应用是本机应用,我希望我的应用在后台运行时不需要运行。 But after I test use software LittleEye, my app consump power, memory, and data when running on background. 但是在我测试使用LittleEye软件后,我的应用在后台运行时会消耗电源,内存和数据。 How the way my app go to sleep when running on the background? 我的应用在后台运行时如何进入睡眠状态? (for prevent battery drain) (为防止电池耗尽)

In Android an app is not automatically killed when in background. 在Android中,应用程序在后台运行时不会自动终止。 It remains in the background stack. 它保留在后台堆栈中。 You need to stop doing background work as soon as your app goes to background. 您的应用程序进入后台后,您需要立即停止后台工作。 Use the onPause/onStop methods of activity lifecycle to handle application's processing when it is in background. 当活动处于后台时,使用活动生命周期的onPause / onStop方法处理应用程序的处理。 If you are using android services in background you can stop/unbind them to avoid unneeded battery use. 如果您在后台使用android服务,则可以停止/取消绑定它们,以避免不必要的电池消耗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM