【问题标题】:Rooted Android Nexus 7 Lollipop disable SystemUI (system + navigation bar) ( C# for Xamarin )Rooted Android Nexus 7 Lollipop 禁用 SystemUI(系统 + 导航栏)(C# for Xamarin)
【发布时间】:2016-04-07 16:50:26
【问题描述】:

我使用以下代码禁用我的 4.4 nexus 设备上的导航栏和状态栏

    try {
            proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "service call activity 42 s16 com.android.systemui" });
        } catch (Exception e) {
            Log.w("Main","Failed to kill task bar (1).");
            e.printStackTrace();
        }
        try {
            proc.waitFor();
        } catch (Exception e) {
            Log.w("Main","Failed to kill task bar (2).");
            e.printStackTrace();
        }

像魅力一样工作。但是当我尝试在我的 Nexus 7 上做同样的事情时。屏幕变黑,我看不到我的应用程序活动。

我在这里做错了吗? android 5.0 的命令有什么不同?

两个设备都已root

【问题讨论】:

    标签: android xamarin xamarin.android root statusbar


    【解决方案1】:

    找到了答案,上面的代码在 Lollipop 上不起作用。以下代码适用于较旧和较新版本的 Android(在 5.0 和 4.4 上测试)。

    private void systemUIEnabled(System.Boolean enabled){
    
            try {
    
                Java.Lang.Process  process = Runtime.GetRuntime().Exec("su");
                DataOutputStream os = new DataOutputStream(process.OutputStream);
                os.WriteBytes("pm " + (enabled ? "enable" : "disable") 
                    + " com.android.systemui\n");
                os.WriteBytes("exit\n");
    
                Toast.MakeText (this, " UI Update , Post Reboot", ToastLength.Long).Show ();
                os.Flush();
            } catch (IOException e) {
                e.PrintStackTrace();
                Toast.MakeText (this, " UI Update , Error", ToastLength.Long).Show ();
            }
    
        }
    

    更新:

    上述解决方案是 C# for Xamarin。下面是Java代码

    public void setSystemUIEnabled(boolean enabled){
    try {
        Process p = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(p.getOutputStream());
        os.writeBytes("pm " + (enabled ? "enable" : "disable") 
                + " com.android.systemui\n");
        os.writeBytes("exit\n");
        os.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
    

    【讨论】:

    • 对不起,我如何在 android studio 上使用它?我粘贴它并在导入后给我一些错误
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    相关资源
    最近更新 更多