how i can add WindowManager
's LayoutParams
flag inside unity c# scripts.
For example i can do it in Android by code as follow.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
you can do that like this:
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"));
i recently doing the same thing,it's work,it float on top of the lock screen,And if the user press HOME key,he will back to the system lock screen.
note that both "/" or "." is just the same. the $ is for inner class,in this case,LayoutParams is the inner class of WindowManager.