Skip to content

Commit 2d1eed7

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 26ec765 + f8cec74 commit 2d1eed7

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package euromsg.com.euromobileandroid.notification;
2+
3+
import android.content.BroadcastReceiver;
4+
import android.content.Context;
5+
import android.content.Intent;
6+
7+
public class NotificationActionBroadcastReceiver extends BroadcastReceiver {
8+
private final NotificationActionListener callback;
9+
10+
public NotificationActionBroadcastReceiver(NotificationActionListener callback) {
11+
this.callback = callback;
12+
}
13+
@Override
14+
public void onReceive(Context context, Intent intent) {
15+
String linkUri = "";
16+
if (intent != null && "ACTION_CLICK".equals(intent.getAction())) {
17+
linkUri = intent.getStringExtra("KEY_ACTION_ITEM");
18+
}
19+
20+
callback.onNotificationActionClicked(linkUri);
21+
}
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package euromsg.com.euromobileandroid.notification;
2+
3+
public interface NotificationActionListener {
4+
void onNotificationActionClicked(String link);
5+
}

euromsg/src/main/java/euromsg/com/euromobileandroid/notification/PushNotificationManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,18 @@ private NotificationCompat.Builder createNotificationBuilder(Context context,
207207
Uri linkUri = Uri.parse(actionItem != null ? actionItem.getUrl() : "");
208208
PendingIntent actionIntent ;
209209
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.R){
210-
actionIntent =(PendingIntent.getActivity(
210+
actionIntent =(PendingIntent.getBroadcast(
211211
context,
212212
0,
213-
new Intent(Intent.ACTION_VIEW, linkUri),
213+
new Intent(context,NotificationActionBroadcastReceiver.class).setAction("ACTION_CLICK").putExtra("KEY_ACTION_ITEM", linkUri),
214214
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
215215
}
216216
else {
217217
actionIntent = (PendingIntent.getActivity(
218218
context,
219219
0,
220-
new Intent(Intent.ACTION_VIEW, linkUri),
221-
PendingIntent.FLAG_UPDATE_CURRENT ));
220+
new Intent(context,NotificationActionBroadcastReceiver.class).setAction("ACTION_CLICK").putExtra("KEY_ACTION_ITEM", linkUri),
221+
PendingIntent.FLAG_UPDATE_CURRENT));
222222
}
223223

224224

0 commit comments

Comments
 (0)