I have an Android app and I'm trying to integrate google cast into it to try it out by following the instructions at https://developers.google.com/cast/cast_2nd-screen_app_tutorial . The app is built with Android API 16 in mind. Because of this, my app wasn't built with the support libraries. However, a condition to using MediaRouteButton is to extend from FragmentActivity.
Converting the code to use the support libraries instead of the non-support equivalents is turning into a big hassle. Is there an alternative component to use for apps supporting only API 11 and higher? Or do I just forego using MediaRouteButton?
(I see I can write my own button to select the device, but I wouldn't be adding any new functionality to this other than to be compatible with my non-FragmentActivity.)
I'm hoping the activity being a FragmentActivity is only a requirement to use the button, and none of the other MediaRouter APIs.
EDIT: Here is the exception that is thrown.
10-24 17:25:02.568: E/AndroidRuntime(25502): FATAL EXCEPTION: main
10-24 17:25:02.568: E/AndroidRuntime(25502): java.lang.IllegalStateException: The activity must be a subclass of FragmentActivity
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.support.v7.app.MediaRouteButton.showDialog(MediaRouteButton.java:225)
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.support.v7.app.MediaRouteButton.performClick(MediaRouteButton.java:285)
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.view.View$PerformClick.run(View.java:18350)
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.os.Handler.handleCallback(Handler.java:730)
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.os.Handler.dispatchMessage(Handler.java:92)
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.os.Looper.loop(Looper.java:137)
10-24 17:25:02.568: E/AndroidRuntime(25502): at android.app.ActivityThread.main(ActivityThread.java:5368)
10-24 17:25:02.568: E/AndroidRuntime(25502): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 17:25:02.568: E/AndroidRuntime(25502): at java.lang.reflect.Method.invoke(Method.java:525)
10-24 17:25:02.568: E/AndroidRuntime(25502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1041)
10-24 17:25:02.568: E/AndroidRuntime(25502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
10-24 17:25:02.568: E/AndroidRuntime(25502): at dalvik.system.NativeStart.main(Native Method)
EDIT 2: Ah, it appears there is a non-support MediaRouteButton version. It detects the chromecast device under its list of available but it doesn't seem to connect. (This version does not have a setRouteSelector
method like the support.v7 version does) but I will try working with this and see if it is an alternative.
EDIT 3: I wrote down what I ended up doing in the Answered section.