所以我正在尝试在我的应用程序中更新chrome cast库(从1.x到2.x)并且转换正在运行但是当我尝试将此添加到我的清单以启用通知时,我得到的包名称不是发现异常。我将此定位为问题的原因是,当我从清单中删除它时,我可以完美地投射。我还想补充一点,我从示例here得到了这个清单声明。
<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());