From ba179cfee8610be3bcc1c2e038d5980a35f1355e Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 18 Sep 2019 18:01:08 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/IntentHelp.kt | 9 +++++++++ .../java/io/legado/app/service/BaseReadAloudService.kt | 2 +- .../java/io/legado/app/service/CheckSourceService.kt | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) 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,