1

I've successfully created kiosk app using Android management API with following policy:

{
  "appAutoUpdatePolicy" : "ALWAYS",
  "applications" : [ {
    "defaultPermissionPolicy" : "GRANT",
    "installType" : "KIOSK",
    "managedConfiguration" : {
      "deviceId" : "36edd69cd4c25e4c"
    },
    "packageName" : "com.example.app"
  } ],
  "blockApplicationsEnabled" : true,
  "bluetoothDisabled" : true,
  "dataRoamingDisabled" : true,
  "debuggingFeaturesAllowed" : true,
  "factoryResetDisabled" : true,
  "installAppsDisabled" : true,
  "keyguardDisabled" : true,
  "name" : "enterprises/LC0xxxxxxx/policies/policy_locked36edd69cd4c25e4c",
  "playStoreMode" : "WHITELIST",
  "safeBootDisabled" : true,
  "screenCaptureDisabled" : true,
  "systemUpdate" : {
    "endMinutes" : 240,
    "startMinutes" : 120,
    "type" : "WINDOWED"
  },
  "uninstallAppsDisabled" : true,
  "version" : "3"
}

After reboot my app is automatically launched preventing access to default home screen. However, about 15 seconds after first launch follows another one, so that app that is already in RESUMED state is launched once again, so old activity and all the fragments it contains are destroyed and replaced with a new instance. I've tried hard to detec what causes two separate launches, but the only clue I got were these two logs following one after another with 15-20 seconds gap:

2020-08-25 13:34:44.111 1074-2694/? I/ActivityManager: START u0 {act=android.intent.action.MAIN typ=null flg=0x10000000 cmp=ComponentInfo{com.example.app/com.example.app.presentation.ui.activities.MainActivity}} from uid 10132

2020-08-25 13:35:00.525 1074-2694/? I/ActivityManager: START u0 {act=null typ=null flg=0x10008000 cmp=ComponentInfo{com.example.app/com.example.app.presentation.ui.activities.MainActivity}} from uid 10136

I've found the way to workaround this issue: I've added BroadcastReceiver that receives ACTION_BOOT_COMPLETED event and writes boolean flag in SharedPreferences. So in MainActivity I check this flag and if it's false I show Splash screen instead of main ui. That's because ACTION_BOOT_COMPLETED is received right between these two launches. But my question is - is there any good way to solve this issue without such "dirty" workaround? I'm pretty sure that two launches of kiosk app is not an expected behavior, but I have no idea what I did wrong.

In case it matters here is also part of my AndroidManifest.xml:

        <activity
        android:theme="@style/AppTheme.Launcher"
        android:name=".presentation.ui.activities.MainActivity"
        android:launchMode="singleTask"
        android:lockTaskMode="if_whitelisted"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.DIAL" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="tel" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.DIAL" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
anro
  • 1,300
  • 16
  • 30
  • Can you provide the package name used for this? Also, the device and OS version will be helpful. – Dave Paurillo Sep 02 '20 at 20:00
  • Package name is com.axmor.fsinphone, device is Samsung Galaxy Tab A 8.0 SM-T295, OS is Android 9. – anro Sep 03 '20 at 02:48
  • I've updated one of devices to Android 10 and this bug is still present. – anro Sep 03 '20 at 03:45
  • @anro Did you manage to find a solution for this one? – makis.k May 20 '23 at 12:03
  • As far as I remember, this appeared to be a bug in my code - I had a broadcast receiver that was capturing SIM_STATE_CHANGED action on device boot and relaunching main activity. – anro May 22 '23 at 13:35

0 Answers0