Android-当用户单击通知时打开浏览器
嗨,我想创建一个通知,当用户点击它时会打开浏览器。但是通知就这样消失了。我已经制作了此代码的多个版本:Android-当用户单击通知时打开浏览器,android,android-intent,browser,notifications,android-pendingintent,Android,Android Intent,Browser,Notifications,Android Pendingintent,嗨,我想创建一个通知,当用户点击它时会打开浏览器。但是通知就这样消失了。我已经制作了此代码的多个版本: private void sendNotification(String url){ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Uri webpage = Ur
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());
}
谢谢您的帮助。问题是url开头没有“http://”。hashString(url)中的这个值是什么?我看不出代码有任何问题,它对我有用,但请检查hashString(url)中的值。hashString(url)的值有效,并显示通知。问题是,当我点击它时,什么都没有发生——浏览器没有显示。