简体   繁体   English

如何在Android中以编程方式启用“屏幕关闭后继续运行”?

[英]How to Programatically Enable “Keep Running After Screen Off” In Android?

I would like my application to always run while the screen is off just like Google Chrome in the following picture: 我希望我的应用程序始终在屏幕关闭时运行,就像下图中的Google Chrome:

在此处输入图片说明

I'm not quite sure how I would enable this button in my application. 我不太确定如何在应用程序中启用此按钮。 Does this button require an extra permission in the manifest file? 此按钮是否需要清单文件中的额外权限?

我认为这不是一个组件或权限,您可以直接使用它。它只会更改一个布尔标志以在代码中使用它。如果希望您的应用在屏幕关闭后继续运行,则应使用android服务并在屏幕变为屏幕时同步状态之所以启用,是因为服务可以在后台继续运行。

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

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