diff --git a/app/src/main/java/io/legado/app/help/IntentHelp.kt b/app/src/main/java/io/legado/app/help/IntentHelp.kt index 28c33ad9e..815867694 100644 --- a/app/src/main/java/io/legado/app/help/IntentHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentHelp.kt @@ -29,4 +29,13 @@ object IntentHelp { PendingIntent.FLAG_UPDATE_CURRENT ) } + + inline fun activityPendingIntent(context: Context, action: String): PendingIntent? { + return PendingIntent.getActivity( + context, + 0, + Intent(context, T::class.java).apply { this.action = action }, + PendingIntent.FLAG_UPDATE_CURRENT + ) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index ad0104675..6ee66129b 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -291,7 +291,7 @@ abstract class BaseReadAloudService : BaseService(), .setContentTitle(nTitle) .setContentText(nSubtitle) .setContentIntent( - IntentHelp.servicePendingIntent(this, "activity") + IntentHelp.activityPendingIntent(this, "activity") ) if (pause) { builder.addAction( diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 75bb49ee0..5fa36c1ba 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -36,7 +36,7 @@ class CheckSourceService : BaseService() { .setContentTitle(getString(R.string.check_book_source)) .setContentText(msg) .setContentIntent( - IntentHelp.servicePendingIntent(this, "activity") + IntentHelp.activityPendingIntent(this, "activity") ) .addAction( R.drawable.ic_stop_black_24dp,