samsung wear watch notification issue

209 views Asked by At

Im trying to show notification on wear watch anything is goes correct but My Remote input choice are not visible on samsung watch it will show only title and Body my input choice are not visible on it.

It appears on my phone, but it doesn't appear on my watch connected to my phone. Is there something missing from the code that's required for Android Wear?

I want to be show this type on notifcation on samsung watch wear

I'm using this code for display notification on watch

public void getNotifcation(){

RemoteInput ri = new RemoteInput.Builder(KEY_TEXT_REPLY) .setLabel(body) .setChoices(replyChoices) .build();
   
 NotificationCompat.Action a =
            new NotificationCompat.Action.Builder(R.drawable.ic_send_arraow_red,
                    null, getReplyPendingIntent())
                    .addRemoteInput(ri)
                    .build();

    Uri defaultSoundUri = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_NOTIFICATION);
   
    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(this, getString(R.string.default_notification_channel_id))
                    .setSmallIcon(R.drawable.ic_noti_icon)
                    .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_notification))
                    .setContentTitle(title)
                    .setContentText(body)
                    .setAutoCancel(true)
                    .setSound(defaultSoundUri)
                    .setVibrate(new long[]{200, 400, 600, 800})
                    .setOngoing(false)
                    .setGroup("GROUP")
                    .setGroupSummary(false)
                    .setContentIntent(notifyPendingIntent)
                    .setPriority(NotificationCompat.PRIORITY_HIGH)
                    .addAction(a)
                    .extend(new NotificationCompat.WearableExtender().addAction(a));



    NotificationCompat.WearableExtender extender =
            new NotificationCompat.WearableExtender();
    extender.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_send_arraow_red, "send" ,
            getReplyPendingIntent())
            .addRemoteInput(ri).build());
    notificationBuilder.extend(extender);

    //Wear OS requires a hint to display the reply action inline.
    NotificationCompat.Action.WearableExtender actionExtender =
            new NotificationCompat.Action.WearableExtender()
                    .setHintLaunchesActivity(true)
                    .setHintDisplayActionInline(true);
    notificationBuilder.addAction(noti.extend(actionExtender).build());


    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(channelId, "Notifications",
                NotificationManager.IMPORTANCE_HIGH);
        notificationChannel.setDescription(messageBody);
        notificationChannel.enableLights(true);
        notificationChannel.enableVibration(true);
        notificationChannel.setVibrationPattern(new long[]{200, 400, 600, 800});
        notificationChannel.setLightColor(Color.RED);
     
        if (defaultSoundUri != null) {
            AudioAttributes audioAttributes = new AudioAttributes.Builder()
                    .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                    .setUsage(AudioAttributes.USAGE_ALARM)
                    .build();

            notificationChannel.setSound(defaultSoundUri, audioAttributes);
        }
     
        notificationManager.createNotificationChannel(notificationChannel);
    }
    
  
    notificationManager.notify(notificationId  notificationBuilder.build());
}

and here is my pending intent to get choice on wear

public void getReplyPendingIntent(){
   Intent intent; 
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // start a // (i)  broadcast      receiver which runs on the UI thread or // (ii) service for a background task to b  executed,will be doing a broadcast receiver
    intent = new Intent(context, FcmBroadcastReceiver.class);
        intent.setAction(REPLY_ACTION);
        intent.putExtra(KEY_NOTIFICATION_ID, notificationId);
        intent.putExtra(KEY_TEXT_REPLY, KeyReply);
        return PendingIntent.getBroadcast(getApplicationContext(), 100, intent,
                PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
    } else {
        // start your activity
        intent = Act_Home.getReplyMessageIntent(this, notificationId, 123);
        return PendingIntent.getActivity(this, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT |        PendingIntent.FLAG_IMMUTABLE);
    }
}
0

There are 0 answers