Testing BootCompleted Event

master
FaizHashmiCS22 5 months ago
parent df571d5b91
commit b4d881d24e

@ -30,8 +30,7 @@
<service <service
android:name=".BootForegroundService" android:name=".BootForegroundService"
android:exported="true" android:exported="true" />
android:foregroundServiceType="location" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"

@ -22,7 +22,7 @@ class BootForegroundService : LifecycleService() {
val channel = NotificationChannel( val channel = NotificationChannel(
channelId, channelId,
"Boot Service Channel", "Boot Service Channel",
NotificationManager.IMPORTANCE_DEFAULT NotificationManager.IMPORTANCE_HIGH
) )
val manager = getSystemService(NotificationManager::class.java) val manager = getSystemService(NotificationManager::class.java)
manager?.createNotificationChannel(channel) manager?.createNotificationChannel(channel)

@ -13,6 +13,7 @@ class BootBroadcastReceiver : BroadcastReceiver() {
Log.d("BootReceiver", "Starting BootForegroundService.") Log.d("BootReceiver", "Starting BootForegroundService.")
val serviceIntent = Intent(context, BootForegroundService::class.java) val serviceIntent = Intent(context, BootForegroundService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// For Android 11 (API level 30) or later
context.startForegroundService(serviceIntent) context.startForegroundService(serviceIntent)
} else { } else {
context.startService(serviceIntent) context.startService(serviceIntent)

Loading…
Cancel
Save