Skip to main content

Setup

Initialize SDK

  • In your MainActivity file, add LastCrashReportSenderListener, initialize the SDK, and configure the lastCrashReportSenderHandleCrash method.
  • Replace LASTCRASH_API_KEY with your LastCrash API key.
  • Additionally, if you'd like to enable freeze detection be sure to add the applicationInitialized call after configure.

Kotlin

class MainActivity {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
LastCrash.configure("LASTCRASH_API_KEY", this, true);
LastCrash.applicationInitialized();
}
}

Java

public class MainActivity {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
LastCrash.configure("LASTCRASH_API_KEY", this, true);
LastCrash.applicationInitialized();
}
}

Optional Listener

Setting the listener is optional. If you would like to control the logic behind sending crash reports then implement the LastCrashReportSenderListener interface and call setCrashReportSenderListener. If no delegate is set then crash reports will be sent automatically.

The lastCrashReportSenderHandleCrash method will be called when crash reports are available to send. This allows you to implement your own logic or ask the user for permission to send crash reports.

LastCrash.sendCrashes() must be called to send the crash reports if the delegate is used.

Kotlin

class MainActivity : LastCrashReportSenderListener {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
LastCrash.setCrashReportSenderListener(this);
LastCrash.configure("LASTCRASH_API_KEY", this, true);
}
...
override fun lastCrashReportSenderHandleCrash() {
// logic here to handle crash
LastCrash.sendCrashes();
}
}

Java

public class MainActivity implements LastCrashReportSenderListener {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
...
LastCrash.setCrashReportSenderListener(this);
LastCrash.configure("LASTCRASH_API_KEY", this, true);
}
...
@Override
public void lastCrashReportSenderHandleCrash() {
// logic here to handle crash
LastCrash.sendCrashes();
}
}