Added back the app updated broadcast receiver to restart it automatically like after a boot
This commit is contained in:
parent
417c4083b5
commit
e91e7d1954
2 changed files with 9 additions and 0 deletions
|
@ -173,6 +173,7 @@
|
|||
<receiver android:name=".core.BootReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
|
|
@ -36,6 +36,14 @@ class BootReceiver : BroadcastReceiver() {
|
|||
serviceIntent.putExtra("StartForeground", true)
|
||||
ContextCompat.startForegroundService(context, serviceIntent)
|
||||
}
|
||||
} else if (intent.action.equals(Intent.ACTION_MY_PACKAGE_REPLACED, ignoreCase = true)) {
|
||||
val autoStart = corePreferences.autoStart
|
||||
Log.i("[Boot Receiver] App has been updated, autoStart is $autoStart")
|
||||
if (autoStart) {
|
||||
val serviceIntent = Intent(Intent.ACTION_MAIN).setClass(context, CoreService::class.java)
|
||||
serviceIntent.putExtra("StartForeground", true)
|
||||
ContextCompat.startForegroundService(context, serviceIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue