Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to handle multiple application classes in android

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.

like image 431
user2072344 Avatar asked Sep 25 '13 09:09

user2072344


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"
 >
like image 88
Biraj Zalavadia Avatar answered Oct 17 '22 21:10

Biraj Zalavadia


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

like image 21
prateekgovill Avatar answered Oct 17 '22 21:10

prateekgovill