From 9967601e3e986f4f8b3d1d7c1782571b99c31330 Mon Sep 17 00:00:00 2001 From: CCG Date: Sun, 8 Dec 2019 20:07:05 +0800 Subject: [PATCH] fix(launch): when open the app from launcher, stay current activity --- app/src/main/AndroidManifest.xml | 2 +- .../java/com/github/kr328/clash/service/ClashNotification.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fa43fa6..eba3776 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ android:name=".MainActivity" android:label="@string/launch_name" android:screenOrientation="portrait" - android:launchMode="singleTask"> + android:launchMode="singleTop"> diff --git a/service/src/main/java/com/github/kr328/clash/service/ClashNotification.kt b/service/src/main/java/com/github/kr328/clash/service/ClashNotification.kt index 6138317..51a5e55 100644 --- a/service/src/main/java/com/github/kr328/clash/service/ClashNotification.kt +++ b/service/src/main/java/com/github/kr328/clash/service/ClashNotification.kt @@ -29,12 +29,14 @@ class ClashNotification(private val context: Service) { .setContentIntent( PendingIntent.getActivity( context, - CLASH_STATUS_NOTIFICATION_ID, + (Math.random() * 100).toInt(), Intent().setComponent( ComponentName.createRelative( context, MAIN_ACTIVITY_NAME ) + ).setFlags( + Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP ), PendingIntent.FLAG_UPDATE_CURRENT )