Automatic migration

Use the following instructions to migrate if you integrated automatically.

  1. In your main Activity, remove the creation of the LocalyticsSession() or LocalyticsAmpSession() member object and remove the call to registerActivityLifecycleCallbacks() in the Activity's onCreate() method. These should be removed in all other Activity classes as well.
    public void onCreate(Bundle savedInstanceState)
    {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
     
       // Remove the following line
       this.localyticsSession = new LocalyticsAmpSession(this.getApplicationContext());
    
       // Remove the next 2 lines
       getApplication().registerActivityLifecycleCallbacks(
             new LocalyticsActivityLifecycleCallbacks(this.localyticsSession));
    
       // Activity Creation Code
    }
  2. If you don't have a custom Application class, create one, and specify the name in your AndroidManifest.xml.
    <application
       android:name=".MyApplication"
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name">
  3. In your Application's onCreate() method, register LocalyticsActivityLifecycleCallbacks.