问题描述
我怎么可以添加的的LayoutParams
统一C#里面的脚本标记。
窗口管理器
例如,我可以用code如下做到在的Android
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);
可以是这样做的:
AndroidJavaObject活动=新AndroidJavaClass(\"com.unity3d.player.UnityPlayer\").GetStatic<AndroidJavaObject>(\"currentActivity\");
AndroidJavaObject赢= activity.Call&LT; AndroidJavaObject&GT;(getWindow);
AndroidJavaObject LP =新AndroidJavaClass(机器人/视图/窗口管理器$的LayoutParams);
win.Call(addFlags,lp.GetStatic&所述; INT&GT(FLAG_SHOW_WHEN_LOCKED));
win.Call(addFlags,lp.GetStatic&LT; INT&GT;(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON));
我最近在做同样的事情,它的工作,它浮在锁屏的上方,而如果用户preSS HOME键,他会回系统锁屏。
请注意,这两个/或。是一样的。在$是内部类,在这种情况下,是的LayoutParams内部类窗口管理的。
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.
这篇关于使用统一的C#脚本的android上面默认锁屏活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!