Getting Errors While Using Notification.builder
I am getting errors with these lines while handling notifications for different API levels. This is how i did so far: ... int currentapiVersion = android.os.Build.VERSION.SDK_INT;
Solution 1:
Use NotificationCompact.Bulider from support liberary (V4 liberary) that supports from 1.6
i think that will solves your problem.
Solution 2:
Finally, with the help of these guys i ended up to the solution of handling the deprecated methods:
if (currentapiVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
notification = newNotification(icon, text, time);
notification.setLatestEventInfo(this, title, text, contentIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNM.notify(NOTIFICATION, notification);
} else {
NotificationCompat.Builderbuilder=newNotificationCompat.Builder(
this);
notification = builder.setContentIntent(contentIntent)
.setSmallIcon(icon).setTicker(text).setWhen(time)
.setAutoCancel(true).setContentTitle(title)
.setContentText(text).build();
mNM.notify(NOTIFICATION, notification);
}
Post a Comment for "Getting Errors While Using Notification.builder"