简体   繁体   中英

Python:- If i want to make an android app to run in background even if the screen is locked. What permission do i need for that from android?

我制作了一个可以检测到应用程序晃动的应用程序,但是只有在手机解锁并运行后才能运行。使任何应用程序在android中在后台运行,以及在手机锁定时我们需要什么权限才能运行该应用程序?

It's a little more complicated than just a permission. You'll need to register a wakelock in your application. A wakelock tells the Android OS not to shut down your application when your device goes to sleep.

Here's the official Android documentation on wakelocks: https://developer.android.com/training/scheduling/wakelock.html

You probably want the section titled "Keeping the CPU on"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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