2

I am developing a standalone application (kiosk mode) for a android 4.0.3 running tablet, my problem is that user can go to the setting using the notification area of system status bar and force stop my app and use the tablet.

I need a hint how the surelock app handles the situation, I downloaded their app on unrooted device , after starting the app and set as default home screen, when I press on notification or recent apps button, the windows pops and hide instantly so user cant interact with it, the same kind of functionality I need in my app.

I have tried System overlay using service, it hides everything behind it (fullscreen), but problem is how i allow only my activity and hide other(like surelock app does).

 WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN,  
        WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
        PixelFormat.OPAQUE);
params.gravity = Gravity.RIGHT | Gravity.TOP;
params.setTitle("Load Average");
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(view, params);
BenMorel
  • 34,448
  • 50
  • 182
  • 322
kadhirvel
  • 470
  • 1
  • 4
  • 17

1 Answers1

0

You can't hide it but you can simply disable it, except home. Try this link. . Using SYSTEM_UI_FLAG_LOW_PROFILE you can dim your system bar and using onWindowFocusChanged() can take the focus and collapse it. If you are using stand alone app just give your application as default home, check the box. Using this user will not able to exit from the application.

code to capture tap events

int count;
public boolean dispatchTouchEvent(MotionEvent event) {
    // Check the event and do magic here, such as...
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        count = count + 1;

        if (count == 1) {
            new CountDownTimer(5000, 1000) {

                public void onTick(long millisUntilFinished) {

                }

                public void onFinish() {
                    count = 0;
                }
            }.start();
        }

        if (count == 15) {

            exitDialog();
        }


    }

    // Be careful not to override the return unless necessary
    return super.dispatchTouchEvent(event);
}

private void exitDialog() {


    new AlertDialog.Builder(ctw)
            .setView(textEntryView)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle("Exit")
            .setCancelable(false)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // if the password is correct we can exit!
                    if (((EditText) textEntryView
                            .findViewById(R.id.exitpassword)).getText()
                            .toString()
                            .compareTo(getString(R.string.exitpassword)) == 0) {


                        // clear everything and call finish.

                    }
                }
            })
            .setNegativeButton("CANCEL",
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog,
                                int which) {


                        }
                    }).show();

}
Community
  • 1
  • 1
PiyushMishra
  • 5,743
  • 6
  • 37
  • 57
  • thnx for ur reply.. but my problem is user can easily access setting and force stop app or revert home screen permission too. I need a solution that user can only my app and admin should have the rights to exit app and explore tablet. – kadhirvel Mar 28 '13 at 07:25
  • @kadhirvel u cant capture the home event so user have option to exit, if user choose ur app to set as default then whenever he click home he will not be able to see launcher otherwise he has two option to exit ur app and launcher.u can provide setting and home button inside your application so its not a problem. For admin case u can write a small code inside timer if within small duration of time 10-15 taps on screen will occur open a dialog box then admin can enter one string if string match to ur static string(ur password) clear the stack, finish all activities and program will exit. – PiyushMishra Mar 28 '13 at 11:21