1

I have an activity that boosts screen brightness

/* turn screen brightness up */ this.getWindow().getAttributes().screenBrightness = 1;

I found out this built in android function crashes some phones.

Is there a more universal way to boost screen brightness?

CQM
  • 39,920
  • 71
  • 218
  • 365

3 Answers3

2

The correct way to set attributes is with setAttributes():

WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.screenBrightness = 1;
this.getWindow().setAttributes(lp);
trutheality
  • 22,216
  • 6
  • 48
  • 65
0

If you want touch events to pass through you need to do more than setting brightness. You need to set view and layout parameters.
view.setFocusable(false);
view.setClickable(false);
view.setKeepScreenOn(false);
view.setLongClickable(false);
view.setFocusableInTouchMode(false);

layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.flags = 280; // You can try LayoutParams.FLAG_FULLSCREEN too
layoutParams.format = PixelFormat.TRANSLUCENT; // You can try different formats
layoutParams.windowAnimations = android.R.style.Animation_Toast; // You can use only animations that the system to can access
layoutParams.type = LayoutParams.TYPE_SYSTEM_OVERLAY;
layoutParams.gravity = Gravity.BOTTOM;
layoutParams.x = 0;
layoutParams.y = 0;
layoutParams.verticalWeight = 1.0F;
layoutParams.horizontalWeight = 1.0F;
layoutParams.verticalMargin = 0.0F;
layoutParams.horizontalMargin = 0.0F;

Take a look at my original post.

Community
  • 1
  • 1
0

You can try the value that is almost 1. For example: 0.999.

inazaruk
  • 73,337
  • 23
  • 185
  • 156