Reputation: 785
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);
Upvotes: 2
Views: 707
Reputation: 91
Add android:exported="true"
in the AndroidManifest for the Activity specified by the intent.
This problem is dependent of Android Version not Samsung.......
Upvotes: 6
Reputation: 81
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.
Upvotes: 0