2

In my app I am sending GCM notification to device, when we click on notification it is not opening app in Samsung S4. Please any one help me.

Code:

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);

    Intent notificationIntent = new Intent(context, Main.class);

    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent intent = PendingIntent.getActivity(context, 0,
            notificationIntent, 0);
    String title = context.getString(R.string.app_name);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    notification.defaults |= Notification.DEFAULT_SOUND;

    notification.defaults |= Notification.DEFAULT_VIBRATE;
    notificationManager.notify(0111, notification);
5

2 Answers 2

6

Add android:exported="true" in the AndroidManifest for the Activity specified by the intent. This problem is dependent of Android Version not Samsung.......

2
  • 1
    where to add this permission ? in application tag or in GCMBaseIntentService in manifest ? i have alreday added same in GCMBaseIntentService still its not opening in S4 it gets opened in rest of the devices
    – Richa
    Dec 9, 2014 at 6:34
  • @Richa add it to the activity started by the Intent, or in the above example, the Main Activity Mar 25, 2015 at 15:57
0

Add android:exported = "true" in the manifest

<activity
            android:name=".G_chat"
            android:label="G_chat"
            android:exported="true">
</activity>

G_chat is the activity which will be opened on the notification click.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.