简体   繁体   English

我想制作一个 Android API 来保持主屏幕中的屏幕唤醒

[英]I want to make an Android API to keep a screen wake in home screen

I want to make an api that makes the screen awake.我想做一个让屏幕唤醒的api。 I have tried this way:我试过这种方式:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

But this is only available when app is running foreground.但这仅在应用程序在前台运行时可用。 If I leave this app, the screen is turn off after a few seconds.如果我离开这个应用程序,屏幕会在几秒钟后关闭。 I want somebody to help me with making this api.我想要有人帮我制作这个 api。 Thank you.谢谢你。

you can use wakelock screen to wakeup the device using api您可以使用唤醒锁屏幕使用 api 唤醒设备

https://developer.android.com/training/scheduling/wakelock#java https://developer.android.com/training/scheduling/wakelock#java

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

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