You must run the application for android in the "Kiosk Mode". It is necessary that the user could not close or minimize the application, as well as enter the device settings.

The task is to make an application for reviews. It will work on a tablet available to customers.

To accomplish the task, I already did the following (using Xamarin):

  • Launched the application as a launcher and deployed the application to full screen:

    [Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon", Theme = "@android:style/Theme.Light.NoTitleBar.Fullscreen")] [IntentFilter(new[] { Intent.ActionMain }, Categories = new[] { Intent.CategoryHome, Intent.CategoryDefault })] 
  • I made the button back event handler blank:

     public override void OnBackPressed(){} 

Now the user can use the notification panel and the home button and the back button. Access to the buttons home and back is not terrible, because the home button returns the user to the application, and the launcher (this application) cannot be closed from the task menu.

You need to block the notification panel or make it almost impossible to use it (so that the user cannot enter the settings, turn off Wi-fi, and so on). There is a root of law .

It is impossible to use electrical tape, colorless varnish, break the touchscreen and other hardware ways to block access to the notification panel.

Supplement 1

Using the following code causes the screen to turn off completely before rebooting. Perhaps if the command to disable only the status bar?

 Java.Lang.Process proc = Java.Lang.Runtime.GetRuntime().Exec( new String[] { "su", "-c", "service call activity 42 s16 com.android.systemui" }); proc.Wait(); 

Supplement 2

When using the programs full! Screen and Hide System Bar (Full Screen) the program is not displayed. Only the desktop image is displayed and nothing else before the reboot. Prestigo multipad weze 3341 3g tablet (PMT 3341_3G), android 5.1.1

  • 2
    As far as I know, in Google, you provided for your impulses and forbade something there to prohibit, such as "so that the client could not minimize or close the application" - JVic
  • Maybe if there is a root of the law, you can somehow somehow remove the status bar? or disable a certain area of ​​the sensor so that the user simply cannot click on the place where you can call the status bar. - mirypoko

6 answers 6

Looks like you need Single-Purpose Devices . Official documentation Set up Single-Purpose Devices

There is also an article in Russian with different hacks on the limitations of user interaction with the device Kiosk Mode application on Android

On Xamarin, you can use any native API, as far as I know. So I think with this problem should arise.

    Kiosk mode is not a full-screen, but a complete lock on the bottom and status bar. Then the user really cannot do anything besides using the program’s functionality (unless of course the program throws an error).

    I had to do such a program, but it was used by means of Android Studio, and not Xamarin. This can be done through the function:

     private void hideBar(){ try { Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 42 s16 com.android.systemui"}); proc.waitFor(); } catch(Exception ex) { Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show(); Log.e("ROOT ERROR", ex.getMessage()); } 

    }

    Or through the shell :

     adb shell su pm disable com.android.systemui //(enable) чтобы включить обратно 

    Perhaps the following commands will help to achieve the desired result with the help of Xamarin.

    From personal experience I advise you to create floating system control buttons (at least "back") that appears when you exit the application. In case the application crashes or you need to change something in the settings, you do not have to turn on the .systemui back.

    • I tried to do as you suggested. After using the function, the screen goes out and does not turn on until the device is rebooted. It is possible, of course, that xamarin is to blame. Can there be a command to simply disable the status bar? I have in the form instead of disabling the entire device interface. On xamarin, the function looks like this: Java.Lang.Process proc = Java.Lang.Runtime.GetRuntime (). Exec (new String [] {"su", "-c", "service call activity 42 s16 com.android.systemui "}); proc.Wait (); - mirypoko
    • @mirypoko through the console did not try? If you do not need to remove / add .systemui dynamically, then this option should suit you. Since you are directly accessing the device as a superuser, you will not have to confirm anything on the device itself. The screen should not turn off. There will be an animation to hide the lower and upper bar. - Igor SKRYL
    • After entering commands from the console, the status bar did not disappear pp.userapi.com/c639530/v639530140/2625d/ZBGBEJuh94o.jpg . Maybe I did something wrong? Maybe the team need to enter in another console? - mirypoko
    • @mirypoko and when you did through the function, then you had a request for the rights of the superuser to perform? If not, then there may be problems with the root access itself. This also indicates that when you accessed the device through the console and ordered to block .systemui nothing happened. I actually never worked with Xamarin , but this is the first logical assumption that came to mind. - Igor SKRYL
    • Always requested the rights of the superuser. Both when using the function, and after entering the su command. When you lock .systemui, the only thing that has changed is that the wallpaper on your desktop is gone. When activated, come back. - mirypoko
     @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return false; } 

    Maybe so?

    • I already deactivated the back button. I need to block access to the status bar, where I can get into the settings. - mirypoko
    • Maybe every time when you try to open the status of a bar, process and run a full screen? - phil
    • one
      Please show me how to do it - mirypoko

    Unfortunately, there is no time to read all your comments, but from what I read, I decided that you only had a problem with blocking the drop-down panel. Try adding a line:

     @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); setContentView(R.layout.activity_main); 

    Well, then read the official documentation

    • I have never understood these docks, stupidly explaining constants, methods, interfaces and other things, I don’t even want to read a large heap, I don’t want to remember anything at all. Hardcore only SO - Flippy

    To block the opening of the statusbar (like the SetupWizard), you need to use the reflection to call the disable method in the android.os.StatusBarManager class. If you need support for all androids, then you will have to climb through the source, as there may be different versions of the method. It seems like they say that it will generate a SecurityException with the requirement to set permissions on the statusbar in the manifest. And this of course will not change anything, in the logs during the installation it will be written that this permission is available only for system applications.

    If there is a root of rights, it changes nothing. In principle, you can transfer the application to the system / app, but in addition to this, the application must be signed by a system certificate, which is almost unrecognizable. But there is one solution: flash devices on CyanogenMod (Lineage) - the system is open there, but I haven’t found any information on this topic.

    As an option, you can put the BusyBox module on your Xposed Framework + module, 100% of it has a statusbar function lock (or even hide it) or some other module, or write your own, Xposed Framework is on the githabe.

    Still? Perhaps bad, but still. When launching the application, rename system / app / SystemUI.apk (or move (or change permish)) and update the graph interface, and close (+ turn on the device (suddenly sit down)) restore ..

    + I do not know whether it is possible. Make a fullscreen application and in onTouchEvent , if action = MOVE (user shifts finger), close the statusbar (method collapsePanels (like) - this can be done without any restrictions.

    PS In any case, when viewing a video in the UC Browser, if you open the statusbar, the video is paused, which means you can put the listener on a slideout (there is fullscreen, a swipe to show the curtain strip stops the video).

    ++ You can instead of using reflection shell poyuzat (close statusbar)

     input swipe 0 100 0 0 

    Ie do svayp on Y from 100 top to zero. You can probably do it in some kind of cycle (?)

    Ideas run out

      I killed the status bar with the Custom Quick Settings application and commands under the root:

       settings put secure user_setup_complete 0 settings put global device_provisioned 0