Adding cast button to ActionBar using the CastCompanionLibrary

android, google-cast

Solution

You have to register your chrome-cast as a testing devise for you to be able to detect the chromecast devise from the Android.

Check the full SDK guide Check the developer console registration. You have to register you chromecast devise in the console here, or else it is not detectable

Update: If nothing works, you may try to publish your app in the chromecast dev console as a last resort.

As mentioned by one of the chromecast developer try to access `http://<chromecast-ip>:9222` from browser and see if you are able to see any thing.

Problem

I am trying to add the cast icon to the ActionBar using the CastCompanionLibrary's 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); // This one return true; } ``` I have this as my menu.xml as specified by the PDF that is included with 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 shows up in the ActionBar. No errors are thrown, nothing at all is visible. If I add a different menu item just to see if everything with my menu is set up correctly, that item shows up fine - it is just this cast action menu item that isn't showing up. I have tried changing the "app" prefixes to "android", but then I get a `NullPointerException` somewhere deep in the library, and I have tried giving the menu item a different, visible icon. Nothing helps. In AndroidStudio, the menu preview shows a menu item with the title "Play on...", so it seems like this should work. What am I doing wrong?

Original source