问题
I am creating a fullscreen app which will run in "kiosk" mode, so the user will not be able to exit. The app is defined as a launcher (home screen).
The Activity
in the manifest is defined with:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Additionally, the Activity
ensures full screen mode with the following in its onCreate()
:
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
However, it seems that the status bar is still accessible. It's hidden by default, but it can still be shown by touching and pulling down the top of the screen (where it shows with a translucent background instead of the usual solid black).
I already know I can prevent this by adding a transparent 10px
system overlay window at the top of the screen which will absorb the touch events. But I removed this hack because I didn't think it was necessary.
I am sure this was all working fine and prevented the status bar from showing without resorting to the hackery. But something has changed somewhere. I have updated to the latest stock firmware and system software - perhaps that has changed this?
The device is currently running Android
4.4.4. I believe it may have been on 4.4.1 before.
Has this ever been possible? Is it more likely that something has changed in Android
or I have broken something, or has this been broken all along and I've only just noticed?
Please note that this is for a specialised industrial device (a Honeywell Dolphin 75e) which cannot be rooted.
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/38530475/android-fullscreen-app-prevent-access-to-status-bar