Reputation: 51
Hi I wanted to create a notification that will open a browser when user clicks on it. But the notification simply disappears and that's it. I have already made houndreds of versions of this code:
private void sendNotification(String url){
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(MediaMonitorService.this,0,intent,0);
long[] vibrations = {250,250,500,250,250};
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(MediaMonitorService.this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("MediaMonitor notification")
.setContentText(notificationMessage)
.setAutoCancel(true)
.setVibrate(vibrations)
.setLights(0xff00ff00,300,1000)
.setContentIntent(resultPendingIntent);
mNotificationManager.notify(hashString(url), mBuilder.build());
}
Thanks for your help.
Upvotes: 1
Views: 1723