![](/img/trans.png)
[英]android- how to trigger notification onclick event? or how to get data only when user clicks on it
[英]Android- Opening a browser when user clicks a notification
嗨,我想創建一個通知,當用戶點擊它時將打開瀏覽器。 但通知只是消失了就是這樣。 我已經制作了這段代碼的houndreds版本:
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://”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.