Android Question Android 5, pinning your app (kiosk)

Harris

Expert
Licensed User
Longtime User
https://www.b4x.com/android/forum/threads/android-kiosk-mode-tutorial.10839/page-7#post-265917

Warwound mentioned a kiosk method in the above post back in Aug 2014.
This feature is now in Lollipop. Has anyone attempted this using a code method?

There are two ways to activate screen pinning:

Manually: Users can enable screen pinning in Settings > Security > Screen Pinning, and select the tasks they want to pin by touching the green pin icon in the recents screen.

Programmatically: To activate screen pinning programmatically, call startLockTask() from your app. If the requesting app is not a device owner, the user is prompted for confirmation. A device owner app can call the setLockTaskPackages() method to enable apps to be pinnable without the user confirmation step.

stopLockTask() will release the screen pinning of your app.

http://www.sureshjoshi.com/mobile/android-kiosk-mode-without-root/

The above article discusses this in some detail, with java code examples.

This method, without user confirmation, seems to provide a needed kiosk solution - that doesn't provide notifications (or access to) and keeps your app as the primary (only app that runes foreground). Also, with a method in your app (password protected), you can unlock the kiosk to perform admin tasks.

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is possible to call these methods with JavaObject. I didn't succeed with becoming a device owner with the dpm tool. It seems that this tool doesn't support receivers that are implemented as inner classes (which is the case with the Administrator library).

This is the command that you should run to make it a device owner:
B4X:
adb shell dpm set-device-owner <your package name>/anywheresoftware.b4a.objects.AdminManager$AdminReceiver
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
It is possible to call these methods with JavaObject. I didn't succeed with becoming a device owner with the dpm tool. It seems that this tool doesn't support receivers that are implemented as inner classes (which is the case with the Administrator library).

This is the command that you should run to make it a device owner:
B4X:
adb shell dpm set-device-owner <your package name>/anywheresoftware.b4a.objects.AdminManager$AdminReceiver
I figured it may be possible with JavaObject - yet not as simple as one would hope.
I use JavaObject calls with another API that was written in java it it works (rather) well.

When (and if) you get time, may you post an example of this usage, since I am not proficient with java calls and code.
This is all (it seems) beyond my level of understanding. Once defined, it often becomes clear(er).

There are other ways to kiosk, as we have explored... Just expanding our horizons with what Android has introduced as simpler approaches.
I wonder thou, if notifications are blocked, if my app will receive (the notification) that a new update needs to be installed?

Coding for everyone and every possible condition is VERY complicated. No???

Thanks
 
Upvote 0
Top