Android. Change system screen brightness immediately - java

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)

Related

Rotate whole android layout

Is it possoble to rotate the whole android userinterface on an eventlistener ?
For example an app which runs in the background and after putting the headphones in the whole interface turn 180° until you put it out again.
Yes it is possible to change layout programmatically (Although not sure about 180 degrees?).
See this link: Change Screen Orientation programmatically using a Button
The first answer he has explained how to change layout programmatically instead of setOnClickListner you can use your eventListener.
EDIT: Look at this:
https://developer.android.com/reference/android/content/Intent.html#ACTION_HEADSET_PLUG
Its the broadcast which takes place in the event a headset was plugged in.

Can't get image to fade in/out with different duration of time

I'm trying to fade my image alpha from 1 to 0 by 2000ms but it seems like it goes rather quickly like half a second. Here's my code:
ImageView tom = (ImageView) findViewById(R.id.imgJerry);
tom.animate().alpha(0f).setDuration(2000);
I'm following a lesson from Udemy and they got it work fine.
You should use Animation on it. Declare the animation in xml and its duration and then refer this in to Code.Yes previous answer is correct..
How to do a fadein of an image on an Android Activity screen?
For those who also face the same problem make sure that you turn on Animation in the developer setting in your android phone.
I've been turn it off for a while and just turn it back to 1x or 0.5x is enough.

Java android - change brightness for my application

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.

How to changed system brightness to the maximum programatically in android

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

zoomable picture - android

How do I make a photo finger-zoomable on a android device? Is there a simple way, or is it complicated? But I dont want zoom buttons. I want it like a phonebrowser, when you take your fingers and drag them from each other on the phone, it will zoom in. How do I do?? I have searched everywhere. If there no way, can I just have two buttons, - and +. If I click one, the "imageview" change size?
How do I make a photo finger-zoomable on a android device? Is there a simple way, or is it complicated? But I dont want zoom buttons. I want it like a phonebrowser, when you take your fingers and drag them from each other on the phone, it will zoom in. How do I do?? I have searched everywhere. If there no way, can I just have two buttons, - and +. If I click one, the "imageview" change size?
Check out this tutorial: http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/1847
The simplest way is to load your image on a WebView and let it do all the work
webView.loadUrl("file://...")

Categories

Resources