I want to enable kiosk mode (Lock Task Mode) in a React Native CLI application. Most of the articles I’ve found are around 6 years old, so I was wondering if there’s a more recent or recommended approach. Any help would be appreciated. Thanks in advance.
React Native does not support Android Kiosk (Lock Task) mode directly,
You must enable it using native Android code
MainActivity@Override
protected void onResume() {
super.onResume();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
startLockTask();
}
}
This enables kiosk mode when the app is in the foreground.
Create a native module and call :
activity.startLockTask(); // To enable
activity.stopLockTask(); // To disable
Without a device owner, Android shows a confirmation dialog, and users can exit.
adb shell dpm set-device-owner com.yourapp/.DeviceAdminReceiver
amboji alur