In my app i am using push notification.it is working fine.but when i remove(clean) the app from the task manager.the push notification is not arriving.what is the problem i don't know.If anyone know how can i resolve this.Please tell me.
This is the method by which i am sending the notification :-
private void sendNotification(String msg) {
mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Log.e("message.....", msg);
if (msg.equals("You Have got New Message")) {
Log.e("msg occuring..", "intent enter in message...");
intent.putExtra("KEYMESSAGE", "Message");
} else {
Log.e("notification occuring..", "notification occurs.....");
intent.putExtra("KEYNOTIFICATION", "aman");
}
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(getNotificationIcon())
.setContentTitle("Telepoh")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
mBuilder.setContentIntent(contentIntent);
mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
mBuilder.getNotification().flags |= Notification.FLAG_ONGOING_EVENT;
mBuilder.setOngoing(false);
mBuilder.setAutoCancel(true);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
My problem is Notification is coming properly when the app in the running state.but when the app remove(Clean) from the task manager the notification is not arriving.Please if anyone know what is the problem.then please tell me.