【问题标题】:Looking for an example of the new Android API setMediaButtonReceiver寻找新的 Android API setMediaButtonReceiver 的示例
【发布时间】:2015-01-05 15:07:09
【问题描述】:

目前我正在使用

  mAudioManager.registerMediaButtonEventReceiver(mRemoteControlResponder);

但现在 在 5.0 中已弃用,并由 setMediaButtonReceiver 取代。 Google 中有 5 个链接都指向 developer.android.com。

有人用过吗?如果可以,可以举个例子吗?

【问题讨论】:

    标签: android android-audiomanager


    【解决方案1】:

    查看此页面:http://grepcode.com/file/repo1.maven.org/maven2/org.robolectric/android-all/5.0.0_r2-robolectric-0/android/media/session/MediaSession.java 这是完整流程的一个相当大的示例。这里是最相关的部分之一

    为您的媒体按钮接收器设置待处理意图,以允许在会话停止后重新开始播放。如果您的应用以这种方式启动,则 android.content.Intent.ACTION_MEDIA_BUTTON 意图将通过待处理意图发送。

    参数:nullmbr 将媒体按钮事件发送到的android.app.PendingIntent。

         public void More ...setMediaButtonReceiver(@Nullable PendingIntent mbr) {
             try {
                  mBinder.setMediaButtonReceiver(mbr);
             } catch (RemoteException e) {
                 Log.wtf(TAG, "Failure in setMediaButtonReceiver.", e);
             }
         }
    

    【讨论】:

    • 第一个链接是正确的,但我不确定你为什么包括其余的,因为 OP 是关于不使用 *MediaButtonEventReceiver。
    • 对不起,我的错误。我想我在睡觉。链接对你有帮助吗?
    • 链接没有响应
    猜你喜欢
    • 2011-06-22
    • 1970-01-01
    • 2014-04-30
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多