Commit b363aadc authored by Denys M's avatar Denys M
Browse files

For #4113. Add extension method for foreground service `PendingIntent`.

parent d7747352
......@@ -17,7 +17,7 @@ import mozilla.components.lib.crash.R
import mozilla.components.lib.crash.prompt.CrashPrompt
import mozilla.components.lib.crash.service.SendCrashReportService
import mozilla.components.support.base.ids.notify
import mozilla.components.support.utils.asPendingIntentForLaunchService
import mozilla.components.support.utils.asForegroundServicePendingIntent
private const val NOTIFICATION_SDK_LEVEL = 29 // On Android Q+ we show a notification instead of a prompt
......@@ -36,7 +36,7 @@ internal class CrashNotification(
val reportPendingIntent = SendCrashReportService
.createReportIntent(context, crash)
.asPendingIntentForLaunchService(context)
.asForegroundServicePendingIntent(context)
val channel = ensureChannelExists(context)
......
......@@ -16,8 +16,8 @@ import android.os.Build
*
* @param context an [Intent] to start a service.
*/
@JvmName("createPendingIntentForLaunchService")
fun Intent.asPendingIntentForLaunchService(context: Context): PendingIntent =
@JvmName("createForegroundServicePendingIntent")
fun Intent.asForegroundServicePendingIntent(context: Context): PendingIntent =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PendingIntent.getForegroundService(context, 0, this, 0)
} else {
......
......@@ -56,9 +56,7 @@ permalink: /changelog/
* `GlobalSyncableStoreProvider.getStore` is no longer part of the public API.
* **support-utils**
* `Intent.asPendingIntentForLaunchService(Context)` extension method
to create pending intent for service that will play nicely with
background execution limitations introduced in Android O.
* `Intent.asForegroundServicePendingIntent(Context)` extension method to create pending intent for the service that will play nicely with background execution limitations introduced in Android O (e.g. foreground service).
# 11.0.0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment