In Android Studio, i'm developing an app that requires the YouTube Data API to be used. I am able to get the API to work, however since the actionbar no longer shows on the device. In the Emulator, however, it shows the action bar. If i extend the "ActionBarActivity" it causes the app to crash because the "YouTubeBaseActivity" needs to be extended. Is there anyway I can extend both of these, or is there a better work around? My code is below.
public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{
public static final String API_KEY = "AIzaSyDWOPhdnXxg0tBLPNDvdRJYtEXgxjUDV-g";
public static final String PlayList_ID = "PLIcQhhPfl0XazBc9_KwIGpvTmm7hECIbI";
private YouTubePlayer youTubePlayer;
private YouTubePlayerFragment youTubePlayerFragment;
private YouTubePlayerView youTubePlayerView;
private MyPlayerStateChangeListener myPlayerStateChangeListener;
private MyPlaybackEventListener myPlaybackEventListener;
private static final int RQS_ErrorDialog = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplayerview);
youTubePlayerView.initialize(API_KEY, this);
myPlayerStateChangeListener = new MyPlayerStateChangeListener();
myPlaybackEventListener = new MyPlaybackEventListener();
}
In the activity_main.xml, the actionbar shows up on the emulator, but not my device. Any help would be much appreciated, as I couldn't find an answer to this anywhere else. Thanks!
There's a better way. Instead of using the YouTubeBaseActivity, use the YouTubePlayerFragment which does not require you to use YouTube's activity.
After that, I recommend using the Toolbar on your own activity that extends AppCompatActivity. You can find a tutorial on how to set the toolbar here