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);
ozbek
  • 20,955
  • 5
  • 61
  • 84
raju
  • 785
  • 3
  • 14
  • 28
  • Please!! check [**Getting Started with Android Push Notification : Latest Google Cloud Messaging (GCM) - step by step complete tutorial**](http://rdcworld-android.blogspot.in/2013/11/android-push-notification-google-cloud.html) may help you – swiftBoy Dec 03 '13 at 06:15
  • ya those steps are completed,my requirement is,in s4 whenever we click on notifications it is not opening the app just hide the notification from notification bar – raju Dec 03 '13 at 06:16
  • Did you checked all the steps, at the end I added code for launching activity when click on Notificatoin. I tested it on couple of Samsung devices and working well. – swiftBoy Dec 03 '13 at 06:18
  • yes,it is working for samsung devices(s duos,grand) but not in s4 – raju Dec 03 '13 at 06:45
  • Check out http://stackoverflow.com/questions/21250364/notification-click-not-launch-the-given-activity-on-nexus-phones for more information – adamdport Mar 18 '15 at 18:23

2 Answers2

6

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

David
  • 11,245
  • 3
  • 41
  • 46
Sendor.Wang
  • 91
  • 1
  • 3
  • 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 09 '14 at 06:34
  • @Richa add it to the activity started by the Intent, or in the above example, the `Main` Activity – Stefan Anca Mar 25 '15 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.

manav patadia
  • 81
  • 1
  • 7