4

I found that notifications triggered while using startForeground() is not showing up in wearables,

ie. for below code,

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 re-write the 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 start displaying it.

So my conclusion is that startForeground() might not be using the 'Compat' version of notification manager to notify.Is there any way I can foreground a service and make the notification it produce to also show up on a wearable without writing a wearable app?

P.S I am talking about a handheld app here not a wear app, the topic of discussion is syncing the notification from a handheld app which is started using startforeground() in a service of the handheld app to auto sync with a wearable.

  • Have you tried building notification using `Notification.Builder` instead of `NotificationCompat.Builder`? – gruszczy Dec 13 '14 at 22:26
  • Notification.Builder is not compatible with wearable's and yes I was using that initially until I tried to bring compatibility with wearables. P.S For anyone reading through all this even if you use NotificationCompat.Builder if you try to make it a onGoing notification it won't show up at all regardless of using the proper code. – king_below_my_lord Dec 15 '14 at 04:40
  • BTW when I talk abt compatibility, please dont mistake it with compatibility for a wear app, I know very well that Notification.Builder can be used inside a wear app, I am talking about writing the code in a handheld once and letting the system sync it automatically. – king_below_my_lord Dec 16 '14 at 12:50
  • check this solution here : http://stackoverflow.com/questions/24631932/android-wear-notification-is-not-displayed-if-flag-no-clear-is-used/24916387#24916387 – pdiddy Aug 06 '15 at 19:43

0 Answers0