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

Commit

Permalink
Open app when notification is clicked
Browse files Browse the repository at this point in the history
Signed-off-by: David Sn <[email protected]>
  • Loading branch information
divadsn committed Oct 9, 2019
1 parent f199d22 commit 196b958
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:name=".activity.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar" />

<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.codebucket.mkkm.service;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.job.JobParameters;
import android.app.job.JobService;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
Expand All @@ -19,6 +21,7 @@

import de.codebucket.mkkm.MobileKKM;
import de.codebucket.mkkm.R;
import de.codebucket.mkkm.activity.SplashActivity;
import de.codebucket.mkkm.database.model.Ticket;
import de.codebucket.mkkm.database.model.TicketDao;
import de.codebucket.mkkm.login.AccountUtils;
Expand Down Expand Up @@ -53,8 +56,12 @@ public void run() {
continue;
}

Intent intent = new Intent(MobileKKM.getInstance(), SplashActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

NotificationCompat.Builder builder = new NotificationCompat.Builder(MobileKKM.getInstance(), Const.ID.EXPIRY_NOTIFICATION_CHANNEL);
builder.setSmallIcon(R.drawable.ic_notification_kkm)
.setContentIntent(PendingIntent.getActivity(MobileKKM.getInstance(), 0, intent, 0))
.setContentTitle(getString(R.string.expiration_notification_title))
.setContentText(getString(R.string.expiration_notification_msg, DATE_FORMAT.format(ticket.getExpireDate())))
.setSound(Uri.parse(prefs.getString("notification_ringtone", null)))
Expand Down

0 comments on commit 196b958

Please sign in to comment.