问题
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