gpt4 book ai didi

android - 单击Cast Mini Controller时android应用崩溃

转载 作者:行者123 更新时间:2023-12-03 05:09:19 25 4
gpt4 key购买 nike

我正在开发使用Chromecast的Android应用程序。该视频正在Chromecast上流式传输,并且Expanded controller也可以运行,但是单击minicontroller应用程序时崩溃了。这是我的日志

java.lang.NullPointerException: class name is null
at android.content.ComponentName.<init>(ComponentName.java:63)
at com.google.android.gms.cast.framework.media.uicontroller.UIMediaController.onLaunchExpandedControllerClicked(Unknown Source)
at com.google.android.gms.cast.framework.media.uicontroller.zzg.onClick(Unknown Source)
at android.view.View.performClick(View.java:4473)
at android.view.View$PerformClick.run(View.java:18780)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)

我在XML中添加了以下片段定义
<fragment
android:id="@+id/castMiniController"
class="com.google.android.gms.cast.framework.media.widget.MiniControllerFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone" />

这是我的依赖
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.2.1'
compile 'com.android.support:mediarouter-v7:v7:26.2.1'
compile 'com.google.android.gms:play-services-cast-framework:15.0.1'
compile 'com.googlecode.android-query:android-query:0.25.9'
}

Gradle版本是3.1.2。注意:我遵循标准程序,没有自定义代码。任何意见,将不胜感激。

最佳答案

如果您还没有在CastOptions类中启动NotificationOptions和CastMediaOptions,则可能是这种情况。请在您的类CastOptions中添加以下行:

NotificationOptions notificationOptions = new NotificationOptions.Builder()
.setTargetActivityClassName(ExpandedControlsActivity.class.getName())
.build();
CastMediaOptions mediaOptions = new CastMediaOptions.Builder()
.setNotificationOptions(notificationOptions)
.setExpandedControllerActivityClassName(ExpandedControlsActivity.class.getName())
.build();

请引用链接 https://codelabs.developers.google.com/codelabs/cast-videos-android/#9

关于android - 单击Cast Mini Controller时android应用崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50576725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com