I want to change system brightness to the maximum when an activity is launched.
I use following examples but they didn't work properly .
Also the system brightness shouldn't change when an application is running.
Change the System Brightness Programmatically
changing screen brightness programmatically in android
How could I achive this process . Any ideas about this ?
Thank you.
You can use this :
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float)WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
getWindow().setAttributes(lp);
You should note that this method doesn't change system settings, and the brightness will be back to normal once the activity is paused or destroyed,
Honestly, I don't remember how to change system settings' brightness, but once I find it out,I will post another answer.
If you want to change brightness back to normal then replace BRIGHTNESS_OVERRIDE_FULL with BRIGHTNESS_OVERRIDE_NONE.
Hope this helps :D
Related
I would like to take a photo with MediaStore.ACTION_IMAGE_CAPTURE intent, but disable the settings button in the top-left corner. I was able to find a EXTRA_SHOW_ACTION_ICONS parameter, but it is not well documented. This is the description:
The name of an Intent-extra used to control the UI of a ViewImage. This is a boolean property that specifies whether or not to show action icons.
Even if I set it true or false, nothing changes. What does this parameter do? I use it like this:
takePictureIntent.putExtra(MediaStore.EXTRA_SHOW_ACTION_ICONS, false);
I would like to take a photo with MediaStore.ACTION_IMAGE_CAPTURE intent, but disable the settings button in the top-left corner
As I have pointed out previously, you do not have control over the UI of a third-party camera apps. There are hundreds of such apps; none have to give you any ability to control their UI.
What does this parameter do?
Based on a search of the Android source code, it does nothing in Android itself. If the device happens to have the AOSP Gallery app installed, it appears to control something in the image viewer there. It is certainly possible that some non-AOSP apps use that extra for some particular reason, but that behavior would vary by app.
I am designing a game in which the player has to change the brightness of his phone in order to pass to the next level.
The idea I have is that there might be an android-permission to allow detect a change in the brightness level.
So my question is that how do I use it in my app.
Thanks in advance.
how can i change application brightness? I know this method
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = (value);
getWindow().setAttributes(layoutParams);
BUT, this method can change just view (activity) brightness, I want to change brightness for all activities in my application. How can I do it?
Also I do not want to change system brightness manually!! So just brightness for all activities JUST in my application.
Thank you for your answers!
I'm not sure there's an easy way to do that. I would save the brightness value the device is on when the user launches the app, then set the brightness to whatever value you want, and reset the brightness to the initial saved value when the user exits the app.
When I click a button in my App, the screen orientation will automatically go to landscape :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
The screen get to landscape successfully but it caused my onConfigurationChanged not working anymore.
I tried to use: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); but it makes no difference.
What should I do, to make the screen go to landscape, when I click the button, without turning off the onConfigurationChanged?Or do you have any other ways to accomplish this?
If you are using API13 or higher as your target,
in your manifest you need to add ScreenSize to your configChanges:
android:configChanges="orientation|screenSize|keyboardHidden"
That should do the trick!
I am making a widget that changes system screen brightness on click.
I did it like on this post
Everything works well, but changings brightness takes approximately 1 second, but I want to change it immediately, like it does default android widget.
How can I do it?
I feel like this question is similar, correct me if I'm wrong
Changing screen brightness programmatically (as with the power widget)