Android Tutorial Android "Kiosk mode" tutorial

mvarela

New Member
Licensed User
Longtime User
I already resolve calling answer validating with phoneState and disable timer in Kiosk Service with this code

B4X:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
   If State = "IDLE" Then
      InCalling = False
   Else
      InCalling = True
   End If
End Sub

but I can't making phone calls yet!
 
Last edited:

Rusty

Well-Known Member
Licensed User
Longtime User
Outstanding ZeroSoft! I added:
B4X:
<action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.HOME" />                
                <category android:name="android.intent.category.DEFAULT" />
to the manifest and followed Erel's idea of KioskServer to my application and now it instantaneously returns to my application.
Further, the Home key starts my application (once the default is set).
Thanks!
One final question, is there a way to programatically stop the association of the home key to the application (for administrative purposes)?
 
Last edited by a moderator:

n3t

Member
Licensed User
Longtime User
timers....

Hello, I am trying to insert a label that displays the time.

In main I put a timer to 500ms but the time is updated at just
about 7 second. Why ?

I use Galaxy tab 10.1 with android 4.04
 

joneden

Active Member
Licensed User
Longtime User
Hi Erel,

Kiosk works really well - thanks for the guide.

I do have one issue with it. I'm using the ZXing lib to allow the user to scan a barcode. As soon as it's launched the kiosk correctly returns control to the app.

If could use a pause function for this and that would work however if the user dropped out of the scanner then the app would not realise and would never pull control back.

Is there a way to detect the currently active app? Then I could allow both mine and the ZXing scanner...

Regards,

Jon
 

joneden

Active Member
Licensed User
Longtime User
Hmmm, looks as though there may have been another issue. It's OK now.

Just to be clear, if launching an intent or class action like ABGetBarcode does that remain under the same application then?
 

joneden

Active Member
Licensed User
Longtime User
Thanks for the feedback - I'll look into this some more and if it works well will try and post my method here for anyone else with the same iss.

I had seen that lib but it looks like very early days, I'm trying to do it myself as I think I'll want to do stuff that the lib won't ever do...

Regards,

Jon
 

coslad

Well-Known Member
Licensed User
Longtime User
No, it can even disable the bottom bar on the tablet, if i set my app as the default luncher, a user can escape clicking the watch icon on the bottom bar.
Please find a way to disable the bar on tablet. thanks

Inviato dal mio GT-P7510 con Tapatalk 2
 

srossi

Member
Licensed User
Longtime User
Hi all, im trying the kiosk example but when i push the home button 4 o 5 times i can do anything i like, kiosk dont starts again, i dont want put the manifest to block home because i dont want my app as home button there is a solution for that thx all
 

mkh42

Member
Licensed User
Longtime User
Hello

I'm new to this Basic4Android and this is my first post.
I came to Basic4Android because I should realise a a little project (Kiosk mode required) for a small museum. With Basic4Android I made quick progress and user part of the app is almost ready. Now I'm implementing the more 'administrative' part of the app.
I first want to use Surelock for Kiosk mode but as I found this thread it seems possible to realise it with Basic4Android.

I played already with the Kiosk demo and found it quit good especially with the addition of homebutton overwrite described in this thread. But one think is really a show stopper for me until now. In my stausbar one can open notification and settings menu. Surlock close this menu immediately so nothing can happen but Kiosk demo unfortunately doesn't until now. The task-manger is a similar problem but not so critical because if I start an other activity main activity starts again.

I found a interesting solution of this problem in this thread

How to disable recent apps dialog on long press home button | Julien Cavandoli - Blog

which can eventually be integrated in the Kiosk app to make it more secure. (and perhaps even can prevent from power down the device by closing the sytem dialog)

here one comment out of the above thread so you can see on a glance what's that all about
"Locked down all system dialogs on 4.1.1 tablet – « Recent Apps », « Notification Bar », even « Power Off »! They may flash but then go away."

The code of the solution seems very simple but for a Basic4Android beginner I have problems to port it. Probably the reflection library can help but there I'm really a beginner. Pherhaps someone can help.

The code from above thread is


B4X:
@Override
public void onWindowFocusChanged (boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
if( !hasFocus && mEnabled )
{
ActivityManager am =   (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
am.moveTaskToFront(getTaskId(),  ActivityManager.MOVE_TASK_WITH_HOME );
sendBroadcast( new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS) );
}
}

importend is also the following
"
It does require android.permission.REORDER_TASKS, which I hadn’t encountered before (can apps even go through the store with that permission?).
"

I would be very happy if someone can help me to port this peace of code and make Kiosk demo app even more usefull.
 
Last edited:

mkh42

Member
Licensed User
Longtime User
I was able to test the code from the above mentioned thread.

http://www.juliencavandoli.com/how-to-disable-recent-apps-dialog-on-long-press-home-button/

I tested the code by importing the kiosk app to eclipse and simply add

B4X:
    @Override 
    public void onWindowFocusChanged(boolean hasFocus) {
       super.onWindowFocusChanged(hasFocus);
     
            Log.d("Focus debug", "Focus changed !");
     
       if(!hasFocus) {
          Log.d("Focus debug", "Lost focus !");
     
          Intent closeDialog = new    Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
          sendBroadcast(closeDialog);
       }
    }

This works great. Task manager, notification bar and system dialog for shut-down are closed immediately after popping up too short to change something.

This code I used is even simpler as the code I stated above but works obviously only for Android < 4.1. For android > 4.1 the little bit more complicate code from my previous post is necessary. (details you can read in the mentioned thread)

If we could port this code to basic4Android the Kiosk app came near a good usable Kiok app.

For me after addition of this code I see only one problem remaining for the moment. After pressing the back button the Kiosk app is often started immediately as it should, but sometimes it takes a couple of seconds to start the kiosk app again.

I will look to find a solution for that.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…