- Home /
Question by
Poranny · Sep 14, 2018 at 05:45 PM ·
androidandroidpluginandroidjavaobjectflag
Error while adding Android flags
Hello everybody :)
I'm trying to add 2 flags in Android, my code:
public static void LockedOn () {
AndroidJavaObject activity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject> ("currentActivity");
AndroidJavaObject win = activity.Call <AndroidJavaObject> ("getWindow");
AndroidJavaObject lp = new AndroidJavaClass("android/view/WindowManager$LayoutParams");
win.Call ("addFlags", lp.GetStatic <int> ("FLAG_SHOW_WHEN_LOCKED"));
win.Call ("addFlags", lp.GetStatic <int> ("FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"));
}
The problem is the flags do their work (the application is shown when the device is locked), but they also crash the entire application (every single code which tried to call this function stops working). I have done a small research and found out that the line where everything stops is the first "win.Call" (the situation is the same when I change their order, they both crash the app the same way). I'd be extremely glad if somebody took their time to help me with this issue :)
Thanks in advance, Poranny.
Comment