StartForeground Fails With Bad Notification For StartForeground
I'm trying to start foreground service but it fails val notificationIntent = Intent(this, MainActivity::class.java) val pendingIntent = PendingIntent.getActivity(this, 0, noti
Solution 1:
Self answer:
It was because of backup content.
In my code, I used SharedPreference to check if the notification channel was created. But BackupManager
saved my SharedPreference even after app was removed, so when the app is reinstalled, notification channel is not created.
I changed AndroidManifest.xml
as shown below and it cleared my SharedPreference. Now it works very well.
<application
android:allowBackup="false"
android:fullBackupOnly="false"
android:fullBackupContent="false"
Post a Comment for "StartForeground Fails With Bad Notification For StartForeground"