Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 196b958

Browse files
committed
Open app when notification is clicked
Signed-off-by: David Sn <[email protected]>
1 parent f199d22 commit 196b958

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
android:name=".activity.MainActivity"
6363
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
6464
android:screenOrientation="portrait"
65-
android:launchMode="singleTop"
65+
android:launchMode="singleTask"
6666
android:theme="@style/AppTheme.NoActionBar" />
6767

6868
<activity

app/src/main/java/de/codebucket/mkkm/service/TicketExpiryCheckService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package de.codebucket.mkkm.service;
22

33
import android.app.NotificationManager;
4+
import android.app.PendingIntent;
45
import android.app.job.JobParameters;
56
import android.app.job.JobService;
67
import android.content.Context;
8+
import android.content.Intent;
79
import android.content.SharedPreferences;
810
import android.net.Uri;
911
import android.os.AsyncTask;
@@ -19,6 +21,7 @@
1921

2022
import de.codebucket.mkkm.MobileKKM;
2123
import de.codebucket.mkkm.R;
24+
import de.codebucket.mkkm.activity.SplashActivity;
2225
import de.codebucket.mkkm.database.model.Ticket;
2326
import de.codebucket.mkkm.database.model.TicketDao;
2427
import de.codebucket.mkkm.login.AccountUtils;
@@ -53,8 +56,12 @@ public void run() {
5356
continue;
5457
}
5558

59+
Intent intent = new Intent(MobileKKM.getInstance(), SplashActivity.class);
60+
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
61+
5662
NotificationCompat.Builder builder = new NotificationCompat.Builder(MobileKKM.getInstance(), Const.ID.EXPIRY_NOTIFICATION_CHANNEL);
5763
builder.setSmallIcon(R.drawable.ic_notification_kkm)
64+
.setContentIntent(PendingIntent.getActivity(MobileKKM.getInstance(), 0, intent, 0))
5865
.setContentTitle(getString(R.string.expiration_notification_title))
5966
.setContentText(getString(R.string.expiration_notification_msg, DATE_FORMAT.format(ticket.getExpireDate())))
6067
.setSound(Uri.parse(prefs.getString("notification_ringtone", null)))

0 commit comments

Comments
 (0)