我遇到了5.0 MediaSession控件的问题 . 我的应用流传输现场音乐,因此我不使用暂停按钮,只使用停止按钮 . 我无法弄清楚如何只在我的磨损设备上显示一个停止按钮.....停止按钮显示并且可以通过手机上的通知正常工作....但是在Moto360上只显示标准的暂停/播放切换 . 当我覆盖onPause()时,我可以从 Watch 中获得正确的行为,但我想在MediaSession回调中使用onStop() . 我不想通过显示暂停按钮来混淆我的用户 .

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));