Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Basic4android Getting started & Tutorials
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4android Getting started & Tutorials Android development starts here. Please do not post questions in this sub-forum.

Android "Kiosk mode" tutorial

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-15-2011, 10:54 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default Android "Kiosk mode" tutorial

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.
Attached Files
File Type: zip Kiosk.zip (5.4 KB, 324 views)
Reply With Quote
  #2 (permalink)  
Old 08-15-2011, 11:23 AM
Newbie
 
Join Date: Apr 2011
Posts: 6
Default

Very nice info!! Thank you!
Reply With Quote
  #3 (permalink)  
Old 08-15-2011, 12:35 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

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).
Reply With Quote
  #4 (permalink)  
Old 08-15-2011, 12:48 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

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?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #5 (permalink)  
Old 08-15-2011, 12:57 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You will be able to run other applications however the main activity will then autoresume itself. Making it nonfunctional.
Reply With Quote
  #6 (permalink)  
Old 08-15-2011, 01:02 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

No woraround this?...

Using a Service module, would I go on restricting access to the device settings and apps?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #7 (permalink)  
Old 08-15-2011, 01:28 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

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.
Reply With Quote
  #8 (permalink)  
Old 11-07-2011, 08:59 AM
Basic4ppc Veteran
 
Join Date: Feb 2008
Posts: 274
Default

Pressing HOME and then going to applications....no problem in emulator.
I mean - does not return to Main activity.
__________________
LG P500, Android v.2.3
Reply With Quote
  #9 (permalink)  
Old 11-07-2011, 10:56 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You should test it on a real device.
Reply With Quote
  #10 (permalink)  
Old 11-09-2011, 08:18 AM
Basic4ppc Veteran
 
Join Date: Feb 2008
Posts: 274
Default

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.
__________________
LG P500, Android v.2.3
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
List of known android "Intents" to do stuff kanaida Basic4android Getting started & Tutorials 8 03-15-2012 09:13 AM
Android Market "Upload a valid APK" tomb Basic4android Updates and Questions 4 05-26-2011 04:18 PM
How should I make a "config" page in Android world ? Andre-K Basic4android Updates and Questions 5 11-26-2010 01:48 PM
Catching the "Shift", "right" & "left" keys linum Questions (Windows Mobile) 3 08-21-2009 01:22 PM
calling the device's "Programs" or "settings" screens HarleyM Questions (Windows Mobile) 0 12-05-2007 02:59 AM


All times are GMT. The time now is 09:59 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0