开发者

Cant use PowerManager's goToSleep APi in android

Hii felas i was making an app and i need to invoke the phone going into screen-saver 开发者_开发知识库mode as i get a triger... I looked around and found out that PowerManager.java does provide such an API "goToSleep"

API description here.

my problem now is that I need a special permission to make this work namely

"android.Manifest.permission.DEVICE_POWER" this permission being a level 2 permission just declaring it in manifest does not provide me with the permission

so now i have to run the app in system thread (have verified it works if i do so ) to get this permission successfully

can anybody provide me any tips or any other way around as how i can make this work without rooting my app (is there some other way to trigger the same behavior


Under a certain brightnes value, the screen goes off so this should work:

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;
lp.screenBrightness = 0;
getWindow().setAttributes(lp);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜