Android fullscreen app - prevent access to status bar

早过忘川 提交于 2019-11-27 16:20:33

However, it seems that the status bar is still accessible.

Yes, because the com.android.systemui package is running which is responsible for the status bar and software navigation bar. The following is a couple of solutions on disabling the package. Note that in order to make use of the solutions the extended privileges (ideally root) are needed.

Reboot persistent solution

Rename the apk extension of /system/app/SystemUI.apk or delete the file completely. You have to remount the /system partition as it is read-only by default. After renaming/deleting the system likely uninstall the /data/data/com.android.systemui package. If not, do it manually, then reboot.

Reboot impermanent solution

Disable/enable the framework service at runtime (e.g. on your app start up) with the calls (valid prior to KitKat at least) to:

service call activity 42 s16 com.android.systemui  // disable status bar

and

am startservice -n com.android.systemui/.SystemUIService  // enable status bar

Note, the solution is not persistent on reboot.

put this code in oncreate method

int myflag= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

getWindow().getDecorView().setSystemUiVisibility(myflag);

for more details https://developer.android.com/training/system-ui/immersive.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!