Adding Application class

If you don’t have an Application class, it’s highly recommended that you add one. If you don’t initialise the SDK in the Application class, you may end up losing the crash data in an App which has one of the following code paths:

More than one Activity

When an Activity crashes, let’s say Activity X, the app opens the last Activity that was running prior to the crashing activity; let’s call the previous Activity Y. Now if your Activity Y doesn’t initialize Hansel you will stop getting the crash reports now on.

Services/Content Providers/Broadcast receivers

If your app has any other app components apart from your Activity, a crash in them won’t get logged if you don’t initialize the SDK in the application class.

 

Adding Application Class

Java class

Create a class called MyApplication and add the following piece of code

import android.app.Application;
import io.hansel.pebbletracesdk.HanselCrashReporter;
public class MyApplication extends Application {
   @Override
   public void onCreate() {
       super.onCreate();
       HanselCrashReporter.getInstance().initializeSDK(this, <hansel_app_id>, <hansel_app_key>);
   }
}

 

Making entry in AndroidManifest.xml

<application

  ...

  android:name=".MyApplication"

  ... >

  ...

</application>

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.