没有 "Open" 操作的通知
Notification without "Open" action
我正在创建一个通知,其中有一个内容点击操作,可以打开我希望它打开的 activity。
Intent myIntent = new Intent(this, WearRunActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, myIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.card_icon)
.setContentTitle("Running...")
.setContentText(chronometer.getText())
.setLargeIcon(BitmapFactory.decodeResource(
getResources(), R.drawable.card_background_blur))
.setAutoCancel(true)
.setOngoing(true)
.setUsesChronometer(true)
.setWhen(initialTime)
.setContentIntent(pendingIntent)
.extend(new NotificationCompat.WearableExtender()
.addAction(new NotificationCompat.Action.Builder(R.drawable.start_icon, "abrir", pendingIntent).build())
.setContentAction(0));
NotificationManagerCompat notification_manager = NotificationManagerCompat.from(this);
notification_manager.notify(1, notificationBuilder.build());
现在,我的通知有 3 "views":
- 内容
- "Open" 按钮
- "Block app" 按钮
如何删除通知上的 "Open" 按钮,以便只有 2 个 "views"、内容和 "block app"?
由于您运行手表上有此代码,您可以注释掉该行
.setContentIntent(pendingIntent)
看看是否能满足您的需求。
我正在创建一个通知,其中有一个内容点击操作,可以打开我希望它打开的 activity。
Intent myIntent = new Intent(this, WearRunActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, myIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.card_icon)
.setContentTitle("Running...")
.setContentText(chronometer.getText())
.setLargeIcon(BitmapFactory.decodeResource(
getResources(), R.drawable.card_background_blur))
.setAutoCancel(true)
.setOngoing(true)
.setUsesChronometer(true)
.setWhen(initialTime)
.setContentIntent(pendingIntent)
.extend(new NotificationCompat.WearableExtender()
.addAction(new NotificationCompat.Action.Builder(R.drawable.start_icon, "abrir", pendingIntent).build())
.setContentAction(0));
NotificationManagerCompat notification_manager = NotificationManagerCompat.from(this);
notification_manager.notify(1, notificationBuilder.build());
现在,我的通知有 3 "views":
- 内容
- "Open" 按钮
- "Block app" 按钮
如何删除通知上的 "Open" 按钮,以便只有 2 个 "views"、内容和 "block app"?
由于您运行手表上有此代码,您可以注释掉该行
.setContentIntent(pendingIntent)
看看是否能满足您的需求。