title: Possible to use MediaRouteButton in an activity other than FragmentActivity?
body: <p>I have an Android app and I'm trying to integrate google cast into it to try it out by following the instructions at <a href="https://developers.google.com/cast/cast_2nd-screen_app_tutorial" rel="nofollow">https://developers.google.com/cast/cast_2nd-screen_app_tutorial</a> . 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.</p>
  
  <p>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?</p>
  
  <p>(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.)</p>
  
  <p>I'm hoping the activity being a FragmentActivity is only a requirement to use the button, and none of the other MediaRouter APIs.</p>
  
  <p><strong>EDIT:</strong> Here is the exception that is thrown.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p><strong>EDIT 2:</strong> Ah, it appears there is a non-support <a href="http://developer.android.com/reference/android/app/MediaRouteButton.html" rel="nofollow">MediaRouteButton</a> version. It detects the chromecast device under its list of available but it doesn't seem to connect. (This version does not have a <code>setRouteSelector</code> method like the support.v7 version does) but I will try working with this and see if it is an alternative.</p>
  
  <p><strong>EDIT 3:</strong> I wrote down what I ended up doing in the Answered section.</p>