wear-osandroid-wear-notification

Notification without "Open" action


I'm creating a notification that has a on content click action that opens the activity that i want it to open.

        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());

Right now, my notification has 3 "views":

How can I delete the "Open" button on the notification in order to have only 2 "views", the content and the "block app"?


Solution

  • Since you are running this code on your watch, you can comment out the line

    .setContentIntent(pendingIntent)
    

    and see if that gives you what you want.