android - 监听按钮点击自定义android通知视图
问题描述
我收到了 webView 发出的通知,在通知上我有按钮 A、B、C。
我想要的是听按钮点击,这样我就可以通过browser.loadUrl("javascript:action()");
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new NotificationCompat.Builder(getApplicationContext(), "notify_001");
contentView = new RemoteViews(getPackageName(), R.layout.custom_push);
contentView.setImageViewResource(R.id.image, R.drawable.logo_32);
Intent switchIntent = new Intent(this, myClassName.class);
PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 1020, switchIntent, 0);
mBuilder.setSmallIcon(R.drawable.blue);
mBuilder.setAutoCancel(false);
mBuilder.setOngoing(true);
mBuilder.setPriority(Notification.PRIORITY_LOW);
mBuilder.setOnlyAlertOnce(true);
mBuilder.build().flags = Notification.FLAG_NO_CLEAR | Notification.PRIORITY_LOW;
mBuilder.setContent(contentView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId = "channel_id";
NotificationChannel channel = new NotificationChannel(channelId, "channel", NotificationManager.IMPORTANCE_LOW);
channel.setVibrationPattern(new long[]{ 0 });
channel.enableVibration(false);
notificationManager.createNotificationChannel(channel);
mBuilder.setChannelId(channelId);
}
notification = mBuilder.build();
notificationManager.notify(NotificationID, notification);
请帮忙。
解决方案
推荐阅读
- javascript - 在 Nunjucks 中获取指定范围的数组
- cygwin - 如何让 cygwin 禁用 fortran?
- c# - Pdf 导出已损坏
- control-m - 为控件 M 中的每个文件名添加时间和增量 1 秒
- json - 将 JSON 解析为多个 Typescript 对象
- php - 如何以选项卡作为链接的形式在所有子域中共享多站点主域的非主菜单?
- python - QMediaPlayer setPlaybackRate > 1 导致高音音频
- java - 最新 FLP api 客户端构建期间的 Android AR Core 异常。回归传统
- reactjs - 使用 React Router 更改链接文本时链接回上一页
- asp.net-mvc - 安装后 x 次不再应用资源翻译