I want to notify the user when message arrived, I used two types of notifications,(New: supported by >=4.1), and the other type is for older device, I write a condition to check the device SDK version and notify by the suitable notyfication type:
if(Build.VERSION.SDK_INT>=4.1) {
Notification notification = new Notification.Builder(context)
.setContentTitle("new message from" + msg.getString(ConstantsGCM.NAME_CLM))
.setContentText(msg.getString(ConstantsGCM.BODYCLM))
.setSmallIcon(icon)
.setLargeIcon(bm)
.setAutoCancel(true)
.setWhen(when).setVibrate(viber)
.setContentIntent(contentIntent)
.build();
if (EntryActivity.useSound.equals("yes"))
if (!ring.equals(""))
notification.sound = (Uri.parse(ring));
else notification.defaults = Notification.DEFAULT_SOUND;
mNotificationManager.notify(110, notification);
}else { //old type..
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.newlogo)
.setContentTitle("new message from" + msg.getString(ConstantsGCM.NAME_CLM))
.setContentText(msg.getString(ConstantsGCM.BODYCLM))
.setContentIntent(contentIntent)
.setLargeIcon(bm)
.setAutoCancel(true)
.setWhen(when);
if (EntryActivity.useSound.equals("yes"))
if (!ring.equals(""))
mBuilder.setSound(Uri.parse(ring));
else mBuilder.setDefaults(Notification.DEFAULT_SOUND);
mNotificationManager.notify(110, mBuilder.build());
}
but In older devices the notifications don't work at all! Any help? point: no errors, no exceptions, just the notification doesn't apeare!
0 comments:
Post a Comment