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.

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

3 Comments

good simple answer, this also maybe of use stackoverflow.com/questions/5003285/java-multiple-inheritance
@bachert we can use maps in the fragments but it supports in Android 3.0 (API level 11)
you could use fragments beginning with api 4 when you use android-support-v4.jar
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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.