Fixed English:
Overview This guide provides the simplest way to create an application in kiosk mode for a single-purpose device. In this mode, only the designated application can be accessed without requiring any root or special permissions.
We will achieve this by utilizing screen pinning, a feature available on all versions of Android devices without the need for root access or special permissions.
Configuration To create the kiosk mode, follow these steps:
-
Include the necessary files from the provided source code.
-
Disable the following components of the Android device for the kiosk mode: a. Back button of the device b. Home button of the device c. Recent task button of the device d. Status bar of the device
By implementing the above steps, your application will run in kiosk mode, ensuring that only the designated application can be accessed on the device without the user having access to other functionalities or applications.
Basic crucks to achieve above -
*. Entry in manifiest -
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
*. Basics permissions
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
*. Ovirride back button
@Override
public void onBackPressed() {
if (!kioskMode.isLocked(this)) {
super.onBackPressed();
}
}
*. override user leave hint method
@Override
protected void onUserLeaveHint() {
super.onUserLeaveHint();
//move current activity to front if required
Log.i(TAG, "onUserLeaveHint()...");
kioskMode.moveTaskToFront(this);
}
/**
* call this from onUserLeaveHint() from every activity
* Ask that the task associated with a given task ID be moved to the
* front of the stack, so it is now visible to the user.
*
* @param activity to move in front
*/
public void moveTaskToFront(Activity activity) {
boolean isLocked = isLocked(activity);
if (!isLocked) {
return;
}
((ActivityManager) activity.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE))
.moveTaskToFront(activity.getTaskId(), 1);
}
*. My kiosk mode singlton class to manage lock unlock -
public class KioskMode {
private static final String TAG = KioskMode.class.getSimpleName();
private static KioskMode kioskMode;
private WindowManager windowManager;
private CustomViewGroup interceptView;
/**
* prevent creating object multiple time
*/
private KioskMode() {
}
For detail configuration please visit-
http://dinkarcse.blogspot.in/2017/06/android-kiosk-modesingle-purpose-app.html