因此,我尝试在我的应用程序中更新 chrome cast 库(从 1.x 到 2.x)并且强制转换正在工作,但是当我尝试将其添加到我的清单以启用通知时,我得到一个包名称未找到异常。我将其作为问题的原因是,当我从清单中删除它时,我可以完美地投射。我还想补充一点,我从这里的示例中得到了这个清单声明。
<receiver android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" >
<intent-filter>
<action android:name="android.media.AUDIO_BECOMING_NOISY" />
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.toggleplayback" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.stop" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.rewind" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.libraries.cast.companionlibrary.action.notificationvisibility" />
</intent-filter>
</service>
<service android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.ReconnectionService"/>
这是完整的错误。
java.lang.IllegalArgumentException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{my.package.name/com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity}
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:247)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:226)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService.getContentIntent(VideoCastNotificationService.java:492)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService.build(VideoCastNotificationService.java:329)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$2.onPostExecute(VideoCastNotificationService.java:233)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$2.onPostExecute(VideoCastNotificationService.java:227)
at android.os.AsyncTask.finish(AsyncTask.java:636)
at android.os.AsyncTask.access$500(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{my.package.name/com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity}
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:314)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:301)
at android.support.v4.app.NavUtils.getParentActivityIntent(NavUtils.java:256)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:240)
at android.support.v4.app.TaskStackBuilder.addParentStack(TaskStackBuilder.java:226)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService.getContentIntent(VideoCastNotificationService.java:492)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService.build(VideoCastNotificationService.java:329)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$2.onPostExecute(VideoCastNotificationService.java:233)
at com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$2.onPostExecute(VideoCastNotificationService.java:227)
at android.os.AsyncTask.finish(AsyncTask.java:636)
at android.os.AsyncTask.access$500(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
这是我在应用程序中初始化 VCM 的方式:
VideoCastManager.initialize(this,
new CastConfiguration.Builder(BuildConfig.CAST_APP_ID).enableNotification()
.enableLockScreen()
.enableWifiReconnection()
.enableCaptionManagement()
.enableDebug()
.addNotificationAction(CastConfiguration.NOTIFICATION_ACTION_PLAY_PAUSE, true)
.build());