I am developing a native android application, in which I am trying to use 2 open-source libraries. Problem is both the libraries are using Application Class in their respective libraries. They are registering these classes in their respective source code in manifest file using "android:name" under the application tag. Question is how to handle such a scenario, since as we know, only ONE tag can be used inside manifest file. Can we register/instantiate the Application Class in the code, so that we mention only ONE library in tag and the second using code/pragmatically. OR are there any other alternatives. Please share your comments/suggestions. Thanks in advance.
Asked
Active
Viewed 2.0k times
31
-
1your scenario is like "ApplicationLib1 extends Application" , "ApplicationLib2 extends Application" and "YourApplication extends Application" ? – Biraj Zalavadia Sep 25 '13 at 10:08
-
You need to implement Multilevel inheritance to resolve this scenario. – Biraj Zalavadia Sep 25 '13 at 10:13
-
2@BirajZalavadia And what we can do if libraries were jar?! In this case we can't write something like this: public Lib2Application extends Lib1Application! – Dr.jacky Jun 20 '14 at 13:11
2 Answers
56
You need to implement Multilevel inheritance to resolve this scenario.
This is your scenario
public Lib1Application extends Application{
}
public Lib2Application extends Application{
}
public YourApplication extends Application{
}
How to resolve this?
public Lib1Application extends Application{
}
public Lib2Application extends Lib1Application{
}
public YourApplication extends Lib2Application{
}
finally in mainfest.xml
<application
android:name="com.your.packagename.YourApplication"
android:icon="@drawable/ijoomer_luncher_icon"
android:label="@string/app_name"
>

Biraj Zalavadia
- 28,348
- 10
- 61
- 77
-
-
Some times you will need to implement it in several places in The Manifest:
-
2And what we can do if libraries were jar?! In this case we can't write something like this: public Lib2Application extends Lib1Application ! – Dr.jacky Jun 20 '14 at 13:11
-
@ Mr.Hyde your point is very nice. Need some more steps to make it work even it is inside .jar files. Just create a separate question and get me the link for that. – Biraj Zalavadia Jun 23 '14 at 04:05
-
@BirajZalavadia Please look at http://stackoverflow.com/questions/24452509 – Dr.jacky Nov 11 '16 at 12:10
1
Only the manifest and application elements are required, they each must be present and can occur only once. Most of the others can occur many times or not at all — although at least some of them must be present for the manifest to accomplish anything meaningful. See this link: http://developer.android.com/guide/topics/manifest/manifest-intro.html#filec

prateekgovill
- 11
- 2