My goal is to run my android app in kiosk mode. In general this works but additionally I want to set the app as standard launcher using adb so the user is not asked on every reboot which launcher app should be used.
So at first I send
pm set-device-owner myPackage/.Receiver" to set the app as device owner for the kiosk mode.
After this I send pm set-home-activity myPackage/.MainActivity" to set it as main activity. But the command returns always with "java.lang.IllegalArgumentException: Component ComponentInfo{myPackage/myPackage.MainActivity} cannot be home on user 0" and I don't know why.
When I reboot the phone I get the selection which Launcher should be used and there I can select the built-in launcher and my app. When I select my app there, it works without problems.
I tried to completely deactivate the built-in launcher by sending pm disable-user --user 0 com.android.launcher3. This actually works immediately and my app is set as home app in kiosk mode. But I do not want to do this because then I have no app drawer etc, when I leave the kiosk of my app.
All I want to do is the selection of the launcher app after reboot via adb without rebooting the device.