Android Tutorial Android "Kiosk mode" tutorial

Erel

Administrator
Staff member
Licensed User
See KioskService code. You will need to change Main with the second activity. Though it might be simpler to use a single activity and change layouts in this case.
 

warwound

Expert
Licensed User
FYO, Android L will have a new API that'll make creation of a kiosk mode app far easier.
It'll be called 'Task Locking', there's some info about it here: http://developer.android.com/preview/api-overview.html#TaskLocking

The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.

To prevent unauthorized usage, only authorized apps can activate task locking. Furthermore, task locking authorization must be granted by a specially-configured device owner app, through the android.app.admin.DevicePolicyManager.setLockTaskComponents() method.
Anyway, back to the present where we have no such API...

Martin.
 

sanjibnanda

Active Member
Licensed User
2) because I was not able to delete recent task list I worked with
a couple of start activities Start0-Start7
That works very well for me no problems with accidentally activating the
original launcher and a long delay
*
Its an excellent work!
+1
I understood the work flow, except the above part, that why you have created these 7 activities and mentioned them in manifest.
could you spare some time to give more information and its functionality.
 

ilan

Expert
Licensed User
i have not read all posts here so i dont know if my question is already answered, so sorry if it is...

will google allow me to upload such an app?? that will always force my app to come to front?
or could it be that my account will be banned by google?
 

Erel

Administrator
Staff member
Licensed User
You will be able to upload your app. I cannot say whether this solution will violate there terms or not.

The kiosk option is more appropriate for specific non-market applications.
 

Declan

Active Member
Licensed User
When I run the eaxmple: KioskAppExtended_vc2
I get the following error:
B4A version: 5.20
Parsing code. Error
Error parsing program.
Error description: Unknown type: controls
Are you missing a library reference?
Occurred on line: 39 (Main)
Dim ICS As Controls
at this section of code:
B4X:
    Dim ICS As Controls
    ICS.Initialize(Activity, Me)
 

Declan

Active Member
Licensed User
When I run the eaxmple: KioskAppExtended_vc2
I get the following error:

at this section of code:
B4X:
    Dim ICS As Controls
    ICS.Initialize(Activity, Me)
Ok, sorted.

But now I have another problem - when I run the example KioskAppExtended, it stops unexpectedly.
 

Erel

Administrator
Staff member
Licensed User
What is KioskAppExtended? Which error do you see in the logs?
 

Declan

Active Member
Licensed User
What is KioskAppExtended? Which error do you see in the logs?
It is this example: KioskAppExtended_vc2
https://www.b4x.com/android/forum/threads/android-kiosk-mode-tutorial.10839/page-6#post-176432

I am trying to create a Kiosk type app that is the device owner - the device must operate as a "reader" similar to a "Kindle"
I require no phone functionality (making and receiving calls), but I must have WiFi and data connections to a server.
My app will be the only app that the user has access to.
I am running Android 5.
 

Rusty

Well-Known Member
Licensed User
I have an application that has successfully used Kiosk mode to manage activities and it has worked well for years.
I recently added VoiceRecognition (in the Phone library), which seems to create a new activity.
In managing the many activities within my app, it is obvious how to deal with activities named by me.
What is the activity name for VoiceRecognition?
B4X:
    Select Case Main.LastActivity.tolowercase.trim
        Case "vr"
            If IsPaused(Main) Then KioskTimer.Interval = 1000
        Case "licensecheck"
            If IsPaused(LicenseCheck) Then KioskTimer.Interval = 1000
        Case "checkupdates"
            If IsPaused(CheckUpdates) Then KioskTimer.Interval = 1000
I have the above code segment within my kioskservice which runs its kiosktimer.
Note the first Case. The vr or activity name is what I am looking for so the kiosk manager can handle it.
Thanks,
Rusty
 
Last edited:

Erel

Administrator
Staff member
Licensed User
It is your code that sets Main.LastActivity. You can set it to whichever value you like before you call VR.Listen. You can disable the timer for 30 seconds before calling Listen.
 

Christian321

Member
Licensed User
Hi guys,

I just started programming with B4A and was willing to develop a kids game. Thus, the kiosk mode would be essential as kids seem to always manage to send an application to the backround.

I now have a question that will probably be easy for you to answer: I tried your kiosk example and I figured that it shows the same behavior similar to my approaches. I tried two very simple ways:

(1) Without a service, in my Main activity:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    StartActivity(Me)    
End Sub
(2) With the Starter service (made sticky) using a 300ms timer:
B4X:
Sub Service_Create
   myWatchdogTimer.Initialize("CheckMainForeground", 300)
   myWatchdogTimer.Enabled = True
End Sub
Sub CheckMainForeground_Tick
    If IsPaused(Main) Then StartActivity(Main)
End Sub
Both ways seem to have the same result. In short, what is the difference to your complex solution?
Many thanks in advance.

Update: I finally managed to get KioskAppExtended running and can see the difference... :cool:
 
Last edited:

Christian321

Member
Licensed User
What is KioskAppExtended?
Hi Erel,

see here: https://www.b4x.com/android/forum/threads/android-kiosk-mode-tutorial.10839/page-5
Post from: mkh42, Jun 19, 2013
Download File KioskAppExtended_vc2.zip

You might need to create the working directory:
B4X:
File.MakeDir(File.DirRootExternal, "Pictures/Screenshots")
I had to find and download quite a lot of required libs. I attached them as Libs.zip.
KioskModeExtended is more like a launcher than an usual kiosk mode app...

Greetings from Germany,
Christian
 

Attachments

Last edited:

Sganga61

Member
Licensed User
Hi
I'm using fine the Kiosk service as suggested by Erel. But now, after upgrading to B4A8, it seems like no more usable....

Any suggestion?
 
Top