Report the last error and total crashes
You can find out the last known error a user encountered as the app crashed, and find out the total number of times the app crashed.
- To find out the hash of the last error, use the getLastCrashID() method:
- To find out how many times your app crashed, use the getTotalCrashesNum() method:
- To reset the crashes counter, use the clearTotalCrashesNum() method:
String lastErrorID = Mint.getLastCrashID();
Note The error hash is only displayed in the Splunk MINT App, where you can create a search to find this value. For more about searching MINT data, see Use the Splunk MINT App in the Splunk MINT App User Guide.
int totalCrashes = Mint.getTotalCrashesNum();
Mint.clearTotalCrashesNum();
Note These methods are blocking, so use them in an AsyncTask class or a thread.
Example code
public MyActivity extends Activity { private final String APIKEY = "TESTAPIKEY"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Mint.initAndStartSession(this.getApplication(), APIKEY); new CheckLastError().execute(); } private class CheckLastError extends AsyncTask<Void, Void, String> { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(Void... params) { int totalCrashes = Mint.getTotalCrashesNum(); if (totalCrashes > 9) { // Get last error hash String lastErrorID = Mint.getLastCrashID(); // Clear the crash counter Mint.clearTotalCrashesNum(); // Return the last error ID return lastErrorID; } return null; } @Override protected void onPostExecute(String lastErrorID) { super.onPostExecute(lastErrorID); // If there are 10 crashes or more and we have a last error ID if (lastErrorID != null) { // Create error URL String errorUrl = "https://mint.splunk.com/dashboard/project/" + APIKEY + "/errors/" + lastErrorID; // Create the URL from your server to send a push notification // or email to the user String myServerUrl = "http://www.myserver.com/notifyUser=" + getUserID(); } } } }
Use the crash callback | Disable network monitoring |
This documentation applies to the following versions of Splunk MINT™ SDK for Android (Legacy): 5.2.x
Feedback submitted, thanks!