I have created a android app using webview
.
I want to show my users (who has installed my android app ) a notification of new blog posts.
When user click on that notification Url should be opened in webview.
I tried like this tutorial.
mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Sets an ID for the notification, so it can be updated
int notifyID = 1;
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
numMessages = 0;
// Start of a loop that processes data and then notifies the user
...
mNotifyBuilder.setContentText(currentText)
.setNumber(++numMessages);
// Because the ID remains unchanged, the existing notification is
// updated.
mNotificationManager.notify(
notifyID,
mNotifyBuilder.build());
But i'm newbie, this is not at all working
Also tried this code in protected void onCreate(Bundle savedInstanceState) {
Intent notificationIntent = new Intent(context, yourwebviewactivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification noti = new NotificationCompat.Builder(context)
.setSmallIcon(icon_small)
.setTicker("ticker message")
.setLargeIcon(largeIcon)
.setWhen(System.currentTimeMillis())
.setContentTitle("title")
.setContentText("message")
.setContentIntent(contentIntent)
//At most three action buttons can be added
.setAutoCancel(true).build();
notificationManager.notify(notifyID, noti);