How do I make a notification started using startForeground () sync its notification with the wearable one?

I found that notifications triggered when using startForeground () function do not show up in wearable files,

t. for the code below,

Intent notIntent = new Intent(this, MainActivity.class);
        notIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendInt = PendingIntent.getActivity(this, 0,
                notIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

        builder.setContentIntent(pendInt)
        .setSmallIcon(R.drawable.play)
        .setTicker(songTitle)
        .setContentTitle("Playing")
        .setContentText(songTitle);
        Notification not = builder.build();
        startForeground(NOTIFY_ID, not);

      

but if i rewrite code like this,

NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

        builder.setContentIntent(pendInt)
        .setSmallIcon(R.drawable.play)
        .setTicker(songTitle)
        .setContentTitle("Playing")
        .setContentText(songTitle);

    NotificationManagerCompat notificationManager =
            NotificationManagerCompat.from(MusicService.this);

    notificationManager.notify(NOTIFY_ID, builder.build());

      

wearbles will start displaying it.

So my conclusion is that startForeground () might not use the Compatibility version of the notification manager for notification. Is there a way that I can override the service and make the notification it produces also appear on the non-write wearable application?

PS I'm talking about a handheld app, there is no wearable app here, the topic of discussion is syncing a notification from a handheld app that is started using startforeground () in the handheld app service to automatically sync with the wearable.

+3


source to share





All Articles