2

I am having issues with the 5.0 MediaSession controls. My app streams live music so I do not use a pause button, only a stop button. I cannot figure out how to only display a stop button on my wear device.....the stop button shows up and works fine from the Notification on my phone....but on Moto360 only displays the standard pause/play toggle. I can get the correct behavior from my watch when I override onPause(), but I want to use onStop() in the MediaSession callbacks. I do not want to confuse my users by showing the pause button.

private void buildNotification(Notification.Action action)
{
    Notification.MediaStyle style = new Notification.MediaStyle();
    style.setMediaSession(mSession.getSessionToken());
    style.setShowActionsInCompactView(0);

    Intent intent = new Intent(getApplicationContext(), Play.class);
    intent.setAction(ACTION_STOP);

    if ((selectedUrl.equals(MouseWorldRadioActivity.radioFiveIP)) || (selectedUrl.equals(MouseWorldRadioActivity.scrIP)))
        {
            PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,                
            new Intent(getApplicationContext(), nowPlaying.class),0);

            Notification.Builder builder = new Notification.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_now_playing)
            .addAction(action)
            .setContentTitle("Mouseworld Radio")
            .setContentText(metaData)
            .setContentIntent(pi)
            .setOngoing(true)
            .setStyle(style);

            lNotificationManager = (NotificationManager)     getSystemService(Context.NOTIFICATION_SERVICE);
            lNotificationManager.notify(NOTIFICATION_ID, builder.build());


//build the notification with stop action---this is called in a different block
buildNotification(generateAction(R.drawable.ic_av_stop, "Stop", ACTION_STOP));
Joeb
  • 95
  • 1
  • 11
  • So the button works as expected, it just displays a pause graphic rather than a stop graphic? – ianhanniballake Jan 02 '15 at 01:28
  • No it does not work unless I override the onPause() method....because it is a pause button, I only want to use onStop() with a Stop button. The notification displays the Stop button and stops playback correctly. It seems like on the watch Google creates the play/pause toggle by default and I cannot figure out how to change that. – Joeb Jan 03 '15 at 15:53
  • Can you help me? http://stackoverflow.com/questions/28637570/android-l-devices-not-sending-notification-card-to-android-wear-smartwatch – arthursfreire Feb 24 '15 at 14:05

0 Answers0