1

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.

Goofy
  • 6,098
  • 17
  • 90
  • 156
saini
  • 233
  • 3
  • 10

3 Answers3

4

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

stefan bachert
  • 9,413
  • 4
  • 33
  • 40
0

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

javahead76
  • 1,050
  • 10
  • 11
0

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

Mayank
  • 8,777
  • 4
  • 35
  • 60