I have an android app that is a device owner which I provision via QR code. I would like to launch the app automatically as soon as the provisioning setup is complete.
I tried to do it using the code below, which works for a normal restart of the device, but not for this particular case.
<receiver
android:name=".receiver.BootCompleteReceiver"
android:enabled="true"
android:directBootAware="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
class BootCompleteReceiver: BroadcastReceiver() {
@SuppressLint("UnsafeProtectedBroadcastReceiver")
override fun onReceive(context: Context, intent: Intent?) {
val startIntent = Intent(context, MainActivity::class.java)
startIntent = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(carlIntent)
}
}
After the setup is complete, the receiver doesn't get any intent.