Java – Android Wear modified the “Open on Phone” button intent

Android Wear modified the “Open on Phone” button intent… here is a solution to the problem.

Android Wear modified the “Open on Phone” button intent

I’m trying to distinguish whether notifications are turned on from watch or phone. Currently I’m trying to set up contentIntent for the notification generator, which also appears on watch as an “open on phone” action. I would like to be able to set up a different intent for watch so that I can add additional parameters to the intent, but I can’t find the right way.

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
        notificationBuilder
                .setContentTitle(contentTitle)
                .setContentText(contentText)
                .setContentIntent(contentIntent)
                .extend(wearableExtender)

I’ve tried adding a wearable extender, but the “open on phone” operation has stopped working. I wonder if there is a way to disable the “Open on Phone” button for wearables and still keep setContentIntent() for phone notifications? I also tried setContentAction() on the extender and the “open on phone” button, but it still doesn’t work.

Any ideas on how to get it to work?

Solution

When you set up PendingIntent for notifications, there is no known way to disable the main action button.

According to developer site for Android wear, the main operation The “Open on phone button is automatically defined by setContentIntent().
Therefore, if you associate a PendingIntent with a notification on a handheld device, it will automatically move to a wearable device with the default action buttons of the same PendingIntent.

Related Problems and Solutions