I am trying to add a translation icon to an ActionBar using the CastCompanionLibrary helper method:
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.main, menu); mDataCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
I have this as my menu.xml, as indicated in the PDF, which is part of the companion library:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/media_route_menu_item" android:title="@string/media_route_menu_title" app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider" app:showAsAction="always"/> </menu>
However, nothing is displayed in the ActionBar. Errors do not arise, nothing is visible. If I add another menu item to check if everything with my menu is configured correctly, this item displays well - it is just an action action menu item that does not display.
I tried changing the prefixes "application" to "android", but then I got a NullPointerException somewhere deep in the library, and I tried to give this menu item a different, visible icon. Nothing helps.
In AndroidStudio, the menu preview displays a menu item that says "Play on ...", so it seems like this should work.
What am I doing wrong?
Scott source share