删除Android导航和顶部栏, [英] Removing Android navigation and topbar,

查看:173
本文介绍了删除Android导航和顶部栏,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在root设备上实现Kiosk应用,我需要完全禁用导航和状态栏。

I am trying to implement a Kiosk app on a rooted android device, and I need to disable the navigation and status bar completely.

这些命令适用于adb shell

These commands works from adb shell

禁用:

service call activity 42 s16 com.android.systemui

启用:

am startservice -n com.android.systemui/.SystemUIService

这很好!现在我需要能够从我的应用程序中执行此操作。所以禁用我试过:

That's good! Now I need to be able to do it from my app. So to disable I've tried:

Process process = Runtime.getRuntime().exec("su service call activity 42 s16 com.android.systemui");

在我的活动中按下按钮时。但没有任何反应,也没有例外。一个吐司突然出现,说该应用程序已获得超级用户权限。

when pressing a button in my activity. But nothing happens, and no exceptions are thrown. A toast pops up though, saying that the app has been given super user rights.

任何想法?

推荐答案

要运行su cmd,您可以使用这个

To run su cmd you can use this

public static void runCmd(String cmd) {
    DataOutputStream os;
    try {
        Process process = Runtime.getRuntime().exec("su");
        os = new DataOutputStream(process.getOutputStream());
        os.writeBytes(cmd + "\n");
        os.writeBytes("exit\n");
        os.flush();
        os.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

要禁用系统ui,您可以运行此命令

To disable system ui you can run this command

runCmd("pm disable com.android.systemui && service call activity 42 s16 com.android.systemui");

如果您想要启用

runCmd("pm enable com.android.systemui && am startservice -n com.android.systemui/.SystemUIService");

这篇关于删除Android导航和顶部栏,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆