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.
3
-
1your scenario is like "ApplicationLib1 extends Application" , "ApplicationLib2 extends Application" and "YourApplication extends Application" ?Biraj Zalavadia– Biraj Zalavadia2013-09-25 10:08:38 +00:00Commented Sep 25, 2013 at 10:08
-
You need to implement Multilevel inheritance to resolve this scenario.Biraj Zalavadia– Biraj Zalavadia2013-09-25 10:13:54 +00:00Commented Sep 25, 2013 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– Dr.jacky2014-06-20 13:11:56 +00:00Commented Jun 20, 2014 at 13:11
Add a comment
|
2 Answers
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"
>
5 Comments
Sunny
how can i use lib2Application class.. please give me an example?
ahmedibrahim085
Some times you will need to implement it in several places in The Manifest: <application android:name="com.example.MyAppClass" android:allowBackup="true"> <activity android:name="com.example.MyAppClass" android:configChanges="locale" android:label="MyAppClass" > <action android:name="com.example.MyAppClass" /> </activity>
Dr.jacky
And what we can do if libraries were jar?! In this case we can't write something like this: public Lib2Application extends Lib1Application !
Biraj Zalavadia
@ 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.
Dr.jacky
@BirajZalavadia Please look at stackoverflow.com/questions/24452509
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