1

First want to give context of my app: when a call is incoming the screen will turn on and will brighten up. same for a text, the screen will turn on for a second.

What I want to do is if a call or text comes in that the screen brightness stays as low as possible. So that the user would not notice the screen turning on. this is more of a service then an activity. as i am trying to do this from the lockscreen where activities cannot be run.

Andrew Irwin
  • 691
  • 12
  • 40
  • Similar questions: http://stackoverflow.com/questions/18312609/change-the-system-brightness-programmatically – headuck Sep 13 '15 at 11:40

1 Answers1

1

Use this snipper.This will wakeup the mobile screen but it will not unlock the screen

PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
wl.acquire();

Or use this

final Window win = getWindow();
win.addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
        WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
        WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
        WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON );

i Got this from here https://android.googlesource.com/platform/packages/apps/DeskClock/+/dfd1960/src/com/android/deskclock/alarms/AlarmActivity.java

hope this will work Happy programming....

Amaresh Jana
  • 732
  • 11
  • 22