Adding multiple application class in AndroidManifest

883 views Asked by At

My android app was needed to add multiDexApplication support. But Now I need to add another custom application class. How can I do that?

//Here's My manifest code:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
    android:name="android.support.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:largeHeap="true">

    <activity
        android:name=".HomeActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".PostActivity"></activity>

</application>

//How can I add my .myApp application class to this?

2

There are 2 answers

0
AudioBubble On

No, That is not possible.

If u need to create two app, set MAIN, LAUNCHER intent filter to two activities

like,

<activity
        android:name=".HomeActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
0
Dkathayat1 On

To use the legacy multidex library there is 3 possibility:

-Declare this class as the application in your AndroidManifest.xml.

-Have your Application extend MultiDexApplication.

-Have your Application override attachBaseContext starting with**

protected void attachBaseContext(Context base) 
super.attachBaseContext(base); 
MultiDex.install(this);

Here is an example ->

class App: MultiDexApplication() {


override fun onCreate() {
    super.onCreate()

    // save version name as static variable for use with Log class and 
}

And delcare the application name in manifest

<application
        android:name=".App"