I use 5 types of notifications in my application. Here is my code as I do:
public class GCMIntentService extends GCMBaseIntentService {
private static int id =0;
NotificationManagerCompat notificationManager;
public GCMIntentService() {
super(SENDER_ID);
}
@Override
protected void onMessage(Context context, Intent intent) {
String title = intent.getStringExtra("title");
String message = intent.getStringExtra("content");
String group = intent.getStringExtra("group");
generateNotification(context,title, message,group);
}
...
private void generateNotification(Context context, String title, String message,String group) {
if(notificationManager==null){
notificationManager = NotificationManagerCompat.from(context);
}
Intent intent = new Intent(context,MyActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_gcm))
.setTicker("Новое сообщение")
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(message)
.setGroup(group)
.setGroupSummary(true)
.build();
notificationManager.notify(id++, notification);
}
}
Notifications come but are not grouped. I want to notice that have one type of grouped. The notification must be updated and it just increase the post count. Give me how to do it. I searched in Google and there but not found a solution.
0 comments:
Post a Comment