Reputation: 10713
In my application I need to disable display power off when device is charging. There is an option in Developer Menu to disable it, so I can to send Intent for user to enable it.
Also I've found info about PowerManager and WakeLocks, but it is for Alarms, I think. And I must to handle, is device charging.
What is the better, or is there another way to do this?
Upvotes: 5
Views: 744
Reputation: 10713
I've do this by that code:
final boolean isStayAwake = isStayAwakeEnabled(context);
if (!isStayAwake) {
intent = new Intent(ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
}
context.startActivity(intent);
There user must check 'stay awake' option
I've used my own ACTION_APPLICATION_DEVELOPMENT_SETTINGS constant because of problems with default one, which have not "com." prefix
Upvotes: 2
Reputation: 33509
Perhaps you want to try FLAG_KEEP_SCREEN_ON
from the WindowManager.LayoutParams
Upvotes: 0