I have written the blog on Medium to achieve Kiosk mode on Android wear. It works fully on Wear OS 2.X and 90% on Wear OS 1.X. Please check on Medium.
Steps :
1: REORDER_TASKS : reorder your app to top in onPause of the app.
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
2: set categories to activity in manifest :
<intent-filter>
<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" />
</intent-filter>
3: Override button’s functionality
public boolean onKeyDown(int keyCode, KeyEvent event){
if (event.getRepeatCount() == 0) {
if (keyCode == KeyEvent.KEYCODE_STEM_1) {
// Do stuff
return true;
} else if (keyCode == KeyEvent.KEYCODE_STEM_2) {
// Do stuff
return true;
} else if (keyCode == KeyEvent.KEYCODE_STEM_3) {
// Do stuff
return true;
}
}
return super.onKeyDown(keyCode, event);
}
4: Disable swipe functionality by applying theme
<style name="AppTheme" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowSwipeToDismiss">false</item>
</style>
5: Relaunch App on Boot
Note :
This functionality is not user friendly and Android Play Store wouldn’t approve of these unless you have a very strong reason