Testing BootCompleted Event

master
FaizHashmiCS22 5 months ago
parent df571d5b91
commit b4d881d24e

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

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

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

Loading…
Cancel
Save