Create Application Class - Android Studio

1. Open your main AndroidManifest.xml
2. Add android:name=".ApplicationClass" to your <application> tag

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test_login_activity">
   <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:name=".ApplicationClass">
        ...
    </application>
</manifest>

3. Hover over android:name=".ApplicationClass" or press Alt + Enter or Option + Enter and select Create class 'ApplicationClass'.

This will automatically create the class for you. You can do so manually if you choose.

4. Now add the onCreate method to your new Application class.

import android.app.Application;

public class ApplicationClass extends Application {
   @Override
   public void onCreate() {
      super.onCreate();
      // TODO: Add OneSignal initialization here
   }
}
import android.app.Application

class ApplicationClass : Application() {
   override fun onCreate() {
      super.onCreate()
      // TODO: Add OneSignal initialization here
   }
}

👍

Next Steps

Continue where you left off "Step 3. Add Required Code"!


Did this page help you?