From 448a432678e5377a54797107038462f0e1fd047f Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 23 Mar 2016 15:17:25 +0100 Subject: [PATCH] open app when clicking notification --- .idea/codeStyleSettings.xml | 231 ++++++++++++++++++ .../NotificationReceiver.java | 11 +- 2 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 .idea/codeStyleSettings.xml diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 0000000..ded962c --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,231 @@ + + + + + + \ No newline at end of file diff --git a/src/de/cweiske/headphoneindicator/NotificationReceiver.java b/src/de/cweiske/headphoneindicator/NotificationReceiver.java index ff0d4a8..4b4c2e3 100644 --- a/src/de/cweiske/headphoneindicator/NotificationReceiver.java +++ b/src/de/cweiske/headphoneindicator/NotificationReceiver.java @@ -2,6 +2,7 @@ package de.cweiske.headphoneindicator; import android.app.Notification; import android.app.NotificationManager; +import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -31,7 +32,15 @@ public class NotificationReceiver extends BroadcastReceiver { .setSmallIcon(R.drawable.headphones_w) .setContentTitle(context.getResources().getString(R.string.plugged)) .setContentText("") - .build() + .setContentIntent( + PendingIntent.getActivity( + context, + 0, + new Intent(context, MainActivity.class), + PendingIntent.FLAG_UPDATE_CURRENT + ) + ) + .build() ); } else { //unplugged -- 2.30.2