We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to set screen brightness maximum but i couldn't do it somehow.
Here is my code:
` void setup(){ fullScreen(JAVA2D);
WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes(); lp.screenBrightness = 1; getActivity().getWindow().setAttributes(lp); } `
void draw(){ //somestuff }
When i run it, application crashes on the phone. Then in the console;
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8128) at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1220) at android.view.View.requestLayout(View.java:20085) at android.view.View.setLayoutParams(View.java:13597) at android.view.WindowManagerGlobal.updateViewLayout(WindowManagerGlobal.java:360) at android.view.WindowManagerImpl.updateViewLayout(WindowManagerImpl.java:97) at android.app.Activity.onWindowAttributesChanged(Activity.java:2858) at android.view.Window.dispatchWindowAttributesChanged(Window.java:894) at com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged(PhoneWindow.java:5057) at android.view.Window.setAttributes(Window.java:925) at processing.test.sketch_161217b.sketch_161217b.setup(sketch_161217b.java:48) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:818)
Answers
Hm. I'm not an Android developer, but that looks like an extremely specific error message.
Did you search for it?
https://www.google.com/search?q=android.view.ViewRootImpl$CalledFromWrongThreadException:+Only+the+original+thread+that+created+a+view+hierarchy+can+touch+its+views
Were any of the top discussion on this specific error helpful?
https://forum.Processing.org/two/discussions/tagged/calledfromwrongthreadexception
And please format your code.
Here is a working example. Tap the screen along the width of the screen (I set it in portrait mode) and you will see a change in brightness.
Kf