I am trying to alter the brightness in a android plugin but i am getting the following error.
AndroidJavaException: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
my unity code
public void Dim()
{
AndroidJNI.AttachCurrentThread ();
AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity");
currentActivity.Call("Dim");
}
android code
public void Dim()
{
WindowManager.LayoutParams WMLP = getWindow().getAttributes();
WMLP.screenBrightness = 0.1f;
getWindow().setAttributes(WMLP);
}
Any help will be appreciated.