Issue
I'm developing an app that displays notifications when there's an incoming event. When the user clicks on the notifications, they will be brought to an activity with a specific fragments within the app. On a Samsung Galaxy Note 2 with Android 4.1.2, this works. However, on a Samsung Galaxy S3 with Android 4.3, the activity does not receive the correct action, but rather receives the intent "android.intent.action.MAIN".
Also, the S3 doesn't seem to get the extras that I'm putting in the intent either. The Note 2 receives them fine.
The notification code is as follows:
Intent launchIntent;
String myType, myAction;
// myType and myAction are programmatically set
launchIntent = new Intent(context, MainActivity.class);
launchIntent.putExtra("Type", myType);
launchIntent.setAction(myAction);
PendingIntent pendingIntent = PendingIntent.getActivity(context, -1, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder noti = new NotificationCompat.Builder(
context).setContentTitle(context.getResources().getString(R.string.app_name))
setContentText(notificationMessage)
setSmallIcon(R.drawable.ic_stat_notify)
setContentIntent(pendingIntent)
setAutoCancel(true)
setWhen(System.currentTimeMillis())
setDefaults(Notification.DEFAULT_ALL);
notificationManager.notify(notifyId, noti.build());
Does anyone know why it works with 1 device and not another? Are there any changes in intent from 4.1 to 4.3?
Thanks.
Solution
OK, turns out I need to set my intent flags to "Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP"
for it to work.
Answered By - user1118764
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.