简体   繁体   English

关闭/锁定屏幕-不启动活动-Android

[英]Turn Off/Lock Screen - Without Launching the Activity - Android

I am developing a simple screen lock application. 我正在开发一个简单的屏幕锁定应用程序。

I want that when I click on the app icon the screen gets locked and turns off. 我希望当我单击应用程序图标时,屏幕被锁定并关闭。 And am also able to do that, BUT before locking the screen the main activity gets launched (Set to Theme.NoDisplay) which takes time to get the device locked, which I don't want to happen. 而且还能够做到这一点, 但是在锁定屏幕之前, 启动主要活动 (设置为Theme.NoDisplay),这花了一些时间来锁定设备,这是我不想发生的。

So is there a way that I can turn off my screen (OR do something like starting Torch) without launching the app activity. 因此,有一种方法可以关闭屏幕(或者执行诸如启动Torch之类的操作)而无需启动应用程序活动。 If required I can also provide the code which i am with. 如果需要,我还可以提供我所使用的代码。

我认为您正在寻找的是android小部件

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

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