> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Moving from Manifest to Code based Integration

> Migrate your MoEngage Android SDK setup from manifest metadata to code-based initialization.

We have deprecated integration on MoEngage SDK via Manifest configuration/tags.\
In the latest integration, you need to initialize the SDK in the `onCreate()` of the application class of your app. Below are the metadata flags you need to remove and equivalent APIs you need to call in the `onCreate()` of your application class.\
If you are already initializing the SDK via code in your Application class you can ignore this.

# Adding App Id

## Then

```text wrap theme={null}
{/*  MANDATORY FIELD: APP ID AS SEEN ON MOENGAGE DASHBOARD APP SETTINGS PAGE  */}
<meta-data
    android:name="APP_ID"
    android:value="XXXXXXXXX" />
```

## Now

```text wrap theme={null}
// this is the instance of the application class and "XXXXXXXXXXX" is the Workspace ID from the dashboard.
MoEngage moEngage = new MoEngage.Builder(this, "XXXXXXXXXXX")
            .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Adding Lifecycle Callbacks

## Then

```text wrap theme={null}
MoEHelper.getInstance(getApplicationContext()).autoIntegrate(this);
```

## Now

Remove the above line from your Application class.

# Adding meta tags to manifest for push notifications

## Then

```text wrap theme={null}
{/*  MANDATORY FIELD: SENDER ID , i.e. THE PROJECT NUMBER AS MENTIONED ON GOOGLE CLOUD CONSOLE PROJECTS PAGE  */}
<meta-data
    android:name="SENDER_ID"
    android:value="id:XXXXXXXXXXXX" />

{/*  MANDATORY FIELD: THE NOTIFICATION SMALL ICON WHICH WILL BE USED TO SET TO NOTIFICATIONS POSTED  */}
<meta-data
    android:name="NOTIFICATION_ICON"
    android:value="@drawable/ic_launcher" />

{/*  MANDATORY FIELD: THE NOTIFICATION LARGE ICON WHICH WILL BE USED TO SET TO NOTIFICATIONS POSTED  */}
<meta-data
   android:name="NOTIFICATION_LARGE_ICON"
   android:value="@drawable/large_icon" />
```

## Now

```text wrap theme={null}
MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXX")
            .setSenderId("xxxxxxx") // required only if you are using GCM.
            .setNotificationSmallIcon(R.drawable.icon)
            .setNotificationLargeIcon(R.drawable.ic_launcher)
            .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Adding meta tags to Skip GCM Registration

## Then

```text wrap theme={null}
<meta-data
    android:name="SKIP_GCM_REGISTRATION"
    android:value="true" />
```

## Now

```text wrap theme={null}
        new MoEngage.Builder(this, "XXXXXXXXXX")
            .setSenderId("xxxxxxx") // required only if you are using GCM.
            .setNotificationSmallIcon(R.drawable.icon)
            .setNotificationLargeIcon(R.drawable.ic_launcher)
            .optOutTokenRegistration()
            .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Showing Multiple Notifications at one go

## Then

```text wrap theme={null}
{/*  OPTIONAL FIELD: THE NOTIFICATION TYPE WHICH WILL BE USED, SINGLE OR MULTIPLE. DEFAULT BEHAVIOR IS SINGLE  */}
<meta-data
    android:name="NOTIFICATION_TYPE"
    android:value="@integer/notification_type_multiple" />
```

## Now

```text wrap theme={null}
MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXX")
            .setSenderId("xxxxxxx") // required only if you are using GCM.
            .setNotificationSmallIcon(R.drawable.icon)
            .setNotificationLargeIcon(R.drawable.ic_launcher)
            .setNotificationType(R.integer.notification_type_multiple)
            .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Setting notification Color

## Then

```text wrap theme={null}
<color name="moe_notification_color">[hex code of color]</color>
```

## Now

```text wrap theme={null}
MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXX")
            .setSenderId("xxxxxxx") // required only if you are using GCM.
            .setNotificationSmallIcon(R.drawable.icon)
            .setNotificationLargeIcon(R.drawable.ic_launcher)
            .setNotificationColor(R.color.colorAccent)
            .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Opt-out BackStack creation for Notification

## Then

```text wrap theme={null}
PushManager.getInstance().optoutBackStackBuilder(true);
```

## Now

```text wrap theme={null}
    MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXX")
            .optOutBackStackBuilder()
            .build();
    MoEngage.initialiseDefaultInstance(moEngage);
```

# Opt-out activity tracking

## Then

```text wrap theme={null}
<activity
    android:name=".SplashScreen"
    android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <meta-data
        android:name="OPT_OUT_TRACKING"
        android:value="true"/>
</activity>
```

## Now

```text wrap theme={null}
ArrayList<Class> trackingOptOut = new ArrayList<>();
trackingOptOut.add(SettingsActivity.class);

MoEngage moEngage =
    new MoEngage.Builder(this, "XXXXXXXXXXX")
        .setTrackingOptOut(trackingOptOut)
        .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Opt-out NavBar

## Then

```text wrap theme={null}
InAppManager.getInstance().optOutNavBar(this,true);
```

## Now

```text wrap theme={null}
    MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXX")
            .optOutNavBar()
            .build();
    MoEngage.initialiseDefaultInstance(moEngage);
```

# Opt-out Activity from showing InApp

## Then

```text wrap theme={null}
<activity
 android:name="[your_activity]">
  <meta-data
    android:name="showInApp"
    android:value="false" />
</activity>
```

## Now

```text wrap theme={null}
ArrayList<Class> inAppOptOut = new ArrayList<>();
inAppOptOut.add(MainActivity.class);
MoEngage moEngage =
    new MoEngage.Builder(this, "XXXXXXXXXX")
        .setInAppOptOut(inAppOptOut)
        .build();
MoEngage.initialiseDefaultInstance(moEngage);
```

# Opt-out of MoEngage extras in Deeplink

## Then

```text wrap theme={null}
PushManager.getInstance().optOutMoEngageExtras(true);
```

## Now

```text wrap theme={null}
    MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXXXX")
            .optOutMoEngageExtras()
            .build();
    MoEngage.initialiseDefaultInstance(moEngage);
```
