Aug 15, 2011 Replies: 135 Edit: A better kiosk implementation is available: https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/#post-518018 Kiosk mode applications are applications that lock the device and do not allow the user to run any other application other than the kiosk application. Android doesn't allow true kiosk mode without building a custom ROM. However using the following methods you can build an application that will prevent "regular" users from playing with anything other than your application. The application is made of two modules. The main activity and a service. The service is configured to start at boot. When the service is started it checks if the activity is running or not. If it is not running it uses a timer to start the main activity. When the activity is paused it schedules the service to start in one second: Code: Sub Activity_Pause (UserClosed As Boolean) If kiosk Then StartServiceAt(KioskService, DateTime.Now + 1 * DateTime.TicksPerSecond, False) End Sub If the user presses on the home screen, the home screen will appear for several seconds. However your application will return to the front after a few seconds and the user will not be able to interact with any other applications or change the settings. The service is set to be a foreground service. This prevents Android from killing our service. Press on the Stop button to deactivate kiosk mode. Attachments Kiosk.zip Kiosk.zip 6.7 KB · Views: 6,571 Last edited: Jul 18, 2017 Click to expand...
Edit: A better kiosk implementation is available: https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/#post-518018 Kiosk mode applications are applications that lock the device and do not allow the user to run any other application other than the kiosk application. Android doesn't allow true kiosk mode without building a custom ROM. However using the following methods you can build an application that will prevent "regular" users from playing with anything other than your application. The application is made of two modules. The main activity and a service. The service is configured to start at boot. When the service is started it checks if the activity is running or not. If it is not running it uses a timer to start the main activity. When the activity is paused it schedules the service to start in one second: Code: Sub Activity_Pause (UserClosed As Boolean) If kiosk Then StartServiceAt(KioskService, DateTime.Now + 1 * DateTime.TicksPerSecond, False) End Sub If the user presses on the home screen, the home screen will appear for several seconds. However your application will return to the front after a few seconds and the user will not be able to interact with any other applications or change the settings. The service is set to be a foreground service. This prevents Android from killing our service. Press on the Stop button to deactivate kiosk mode.
Erel B4X founder Staff member Licensed User Longtime User Aug 15, 2011 #3 The files in the first post were updated to better save battery power when device is sleeping. Note that Sub Activity_Pause will be raised multiple times when the device power button is pressed as the service tries to resume the activity (Activity_resume will not be called).
The files in the first post were updated to better save battery power when device is sleeping. Note that Sub Activity_Pause will be raised multiple times when the device power button is pressed as the service tries to resume the activity (Activity_resume will not be called).
Cableguy Expert Licensed User Longtime User Aug 15, 2011 #4 I was wondering if something like it would be possible... I have some questions... 1- Using the "kiosk" as a front-end, is it possible to run other Apps? (I guess that using and intend should do the job?) 2- when one of those apps is terminated, is the "Kiosk" Foregrounded immediatly? 3- Is it possible to set restricions of usage in some "services", like web access, Market, etc?
I was wondering if something like it would be possible... I have some questions... 1- Using the "kiosk" as a front-end, is it possible to run other Apps? (I guess that using and intend should do the job?) 2- when one of those apps is terminated, is the "Kiosk" Foregrounded immediatly? 3- Is it possible to set restricions of usage in some "services", like web access, Market, etc?
Erel B4X founder Staff member Licensed User Longtime User Aug 15, 2011 #5 You will be able to run other applications however the main activity will then autoresume itself. Making it nonfunctional.
You will be able to run other applications however the main activity will then autoresume itself. Making it nonfunctional.
Cableguy Expert Licensed User Longtime User Aug 15, 2011 #6 No woraround this?... Using a Service module, would I go on restricting access to the device settings and apps?
No woraround this?... Using a Service module, would I go on restricting access to the device settings and apps?
Erel B4X founder Staff member Licensed User Longtime User Aug 15, 2011 #7 The code in the first post will disable device settings and all other applications. It is not possible using this code to allow some applications and restrict others.
The code in the first post will disable device settings and all other applications. It is not possible using this code to allow some applications and restrict others.
peacemaker Expert Licensed User Longtime User Nov 7, 2011 #8 Pressing HOME and then going to applications....no problem in emulator. I mean - does not return to Main activity.
Pressing HOME and then going to applications....no problem in emulator. I mean - does not return to Main activity.
Erel B4X founder Staff member Licensed User Longtime User Nov 7, 2011 #9 You should test it on a real device.
peacemaker Expert Licensed User Longtime User Nov 9, 2011 #10 Tested. Almost OK, but .... HOME button and then SETTINGS menu (system settings where applications can be stopped) - is not blocked :-( On real device, sure. If to go back from SETTINGS - Main activity again OK.
Tested. Almost OK, but .... HOME button and then SETTINGS menu (system settings where applications can be stopped) - is not blocked :-( On real device, sure. If to go back from SETTINGS - Main activity again OK.
Erel B4X founder Staff member Licensed User Longtime User Nov 9, 2011 #11 Android doesn't allow true kiosk mode without building a custom ROM. Click to expand... There is no true kiosk mode in Android.
Android doesn't allow true kiosk mode without building a custom ROM. Click to expand... There is no true kiosk mode in Android.
D DKCERT Member Licensed User Longtime User Nov 18, 2011 #12 peacemaker said: Tested. Almost OK, but .... HOME button and then SETTINGS menu (system settings where applications can be stopped) - is not blocked :-( On real device, sure. If to go back from SETTINGS - Main activity again OK. Click to expand... Form a security point of view this is good! If true kiosk mode was possible a mobile botnet would be up and running in no-time!
peacemaker said: Tested. Almost OK, but .... HOME button and then SETTINGS menu (system settings where applications can be stopped) - is not blocked :-( On real device, sure. If to go back from SETTINGS - Main activity again OK. Click to expand... Form a security point of view this is good! If true kiosk mode was possible a mobile botnet would be up and running in no-time!
AscySoft Active Member Licensed User Longtime User Nov 24, 2011 #14 Imagine that I put an kiosk app on a phone running android; then someone calls you. Could I answer the phone? If not, how could I circumvent this?
Imagine that I put an kiosk app on a phone running android; then someone calls you. Could I answer the phone? If not, how could I circumvent this?
Erel B4X founder Staff member Licensed User Longtime User Nov 27, 2011 #15 You will be able to answer the phone.
Z ZeroSoft Member Licensed User Longtime User Jan 13, 2012 #16 hi, Erel can you please explain me for what is the "limitNumberOfTicks" code. Thx.
Erel B4X founder Staff member Licensed User Longtime User Jan 15, 2012 #17 The purpose of limitNumberOfTicks is to pause the timer when the device goes to sleep. Otherwise when the user presses on the power button the timer will continue ticking and sending StartActivity messages until the CPU is paused. This variable pauses the timer after one second.
The purpose of limitNumberOfTicks is to pause the timer when the device goes to sleep. Otherwise when the user presses on the power button the timer will continue ticking and sending StartActivity messages until the CPU is paused. This variable pauses the timer after one second.
R ribber Member Licensed User Longtime User Jan 26, 2012 #18 Great tutorial Erel! Very helpful! One question. If I press the home button on my galaxy s II the kiosk mode needs 4-5 seconds to bring the activity in foreground. Is it possible reduce this time period? Thank you!
Great tutorial Erel! Very helpful! One question. If I press the home button on my galaxy s II the kiosk mode needs 4-5 seconds to bring the activity in foreground. Is it possible reduce this time period? Thank you!
Erel B4X founder Staff member Licensed User Longtime User Jan 27, 2012 #19 The service is scheduled to run 1 second after the activity is paused. You can try reducing it to 200ms. It may save 800ms.
The service is scheduled to run 1 second after the activity is paused. You can try reducing it to 200ms. It may save 800ms.