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 successfullycan 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);
精彩评论