gpt4 book ai didi

android通知点击不工作

转载 作者:行者123 更新时间:2023-11-29 21:08:53 24 4
gpt4 key购买 nike

我在服务中使用这段代码,以便在我有任何新警报时收到通知,但是当我点击它们时,我没有进入我想要的 View :

if(newAlertCounter > 0) // alert user about new alerts
{
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_action_warning)
.setContentTitle(newAlertCounter + " new flood alerts!")
.setContentText("Tap to see where in your vecinity.");

// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());

// notification click action
Intent notificationIntent = new Intent(this, ViewAlertsActivity.class);

PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

mBuilder.setContentIntent(resultPendingIntent);
}

它显示了但无法点击,这是怎么回事?

最佳答案

mNotifyMgr.notify(mNotificationId, mBuilder.build()); 

之后

mBuilder.setContentIntent(resultPendingIntent);

关于android通知点击不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23597780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com