I am developing a Cordova application which should run in a "Kiosk" mode - the device will be locked to that app and should not be able to exit.
To achieve this I am using a slightly modified version of cordova-plugin-kiosk, which provides an extra activity (KioskActivity
) that is defined as a launcher (it has android.intent.category.HOME
).
This works reasonably well. However, the app still has the original cordova MainActivity, which causes some confusion, especially as this is what gets launched by the icon in the original launcher, and by the cordova run android
command. It also results in two entries in the Chrome remote inspector.
The AndroidManifest.xml
looks like this at the moment:
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|uiMode" android:label="@string/activity_name" android:launchMode="singleInstance" android:name="jk.cordova.plugin.kiosk.KioskActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
I would like to merge these into a single activity and do away with the confusion.
I can see 2 possible ways to do this:
- Find a way to remove the
MainActivity
section from theAndroidManifest.xml
, and hopefully also to makecordova run android
runKioskActivity
instead. - Find a way to modify
MainActivity
and move the code fromKioskActivity
into it.
However, I cannot find any sensible way to achieve either of these without causing more confusion by breaking all the cordova tools.