0

I've successfully converted most of my app to use ActionBarCompat by extending ActionBarActivity on most activities, however... I have a MapActivity class and need this to work here as well.

How would I go about creating a new class based on ActionBarActivity and having it extend MapActivity and would that even work?

The sample that Google provides in the ../samples/android-17/ActionBarCompat directory has a lot of these java files (ActionBarActivity.java, etc.) but also tons of required layouts, styles, drawables, etc., etc. and I wasn't sure if adding all of those files to my project is the only way to get this one map screen to work. Seems like there has to be a better way right?

Brian Crider
  • 314
  • 3
  • 13

1 Answers1

2

You can't create an activity that inherits from both. You'll have to create a MapFragment.

Krylez
  • 17,414
  • 4
  • 32
  • 41
  • This looks like a viable option, will investigate what it'll take to convert what I have to this. I was originally thinking more on the lines of: myMapActivity extends MyActionBarActivity. MyActionBarActivity would extend MapActivity (similar to how the original google ActionBarActivity extends Activity). Seems google would have created an ActionBarMapActivity in their library to solve this for both Activity types. – Brian Crider Jul 31 '13 at 21:05
  • I think the fact that there is no ActionBarMapActivity was very intentional. – Krylez Jul 31 '13 at 21:31
  • I also see a SupportMapFragment, will try that since I'm trying to support 2.x users as well. – Brian Crider Jul 31 '13 at 23:54
  • To elaborate, the old v1 map activity doesn't support maps as fragments. The original MapView API is in the process of being deprecated in favor of the v2 maps linked above. The main requirement for this is the Google Play Services library, which is backwards compatible to i believe 2.3. http://developer.android.com/google/play-services/setup.html – Travis Castillo Nov 22 '13 at 21:10