Android ChromeCast: Tapping on my MiniControllerFragment doesn't open the ExpandedControllerActivity

假装没事ソ 提交于 2021-02-10 05:01:02

问题


I have an app that has a MiniControllerFragment in the layout:

 <fragment
        android:id="@+id/cast_mini_controller"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:visibility="visible"
        app:castShowImageThumbnail="true"
        app:
        class="com.google.android.gms.cast.framework.media.widget.MiniControllerFragment" />

I also have an ExpandedControllerActivity subclass:

public class ExpandedControlsActivity extends ExpandedControllerActivity {

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.expanded_controller, menu);
        CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item);
        return true;
    }
}

The MiniController works. When casting, the play/pause buttons work fine. However, tapping on the MiniController does nothing. It is supposed to open the ExpandedController, but I don't see how my MiniController is supposed to know which Activity to start. Is there additional code or something in the manifest I need to add?


回答1:


When you construct your CastOptions, using its Builder, you need to pass in a CastMediaOption. This latter class (CastMediaOption) can be constructed using its Builder, which takes the name of your expanded controller activity, by calling setExpandedControllerActivityClassName().



来源:https://stackoverflow.com/questions/39048495/android-chromecast-tapping-on-my-minicontrollerfragment-doesnt-open-the-expand

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!