Is there way to inherit two different activities in android. I have to display the Map on my activity which inherit from some other activity. i want to display a map on that activity but i can't display the map without inheriting MapActivity. Is there any other way to display the map without using MapActivity.
3 Answers
No, android is java based. And java do not support multiple inheritance. Java supports multiple interfaces.
Maybe using fragments will help. Fragments could simulate multiple activities. However, all "activities" must be available as fragment. I am not sure whether there exist one for maps

- 9,413
- 4
- 33
- 40
-
good simple answer, this also maybe of use http://stackoverflow.com/questions/5003285/java-multiple-inheritance – Graham Smith Mar 29 '12 at 08:12
-
@bachert we can use maps in the fragments but it supports in Android 3.0 (API level 11) – saini Mar 29 '12 at 10:05
-
you could use fragments beginning with api 4 when you use android-support-v4.jar – stefan bachert Mar 29 '12 at 11:39
I modified the pattern listed by Mayank to assume that one base Activity doesn't change. I also made some tweak to show how arguments would work, considering activities will need access to base activity. In the following link, assume map activity would be BaseActivityAlpha. Here is my posting: http://www.anotherandroidblog.com/2013/01/03/extending-from-two-activities

- 1,050
- 10
- 11
java does not support Multiple Inheritance, although you can come up with a clever design that will let you use functionality of multiple objects in your Activity.
read following article
http://csis.pace.edu/~bergin/patterns/multipleinheritance.html

- 8,777
- 4
- 35
- 60