Splunk MINT SDK for Android

Splunk MINT SDK for Android Developer Guide

Download manual as PDF

Download topic as PDF

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:
  • 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.

  • To find out how many times your app crashed, use the getTotalCrashesNum() method:
  • int totalCrashes = Mint.getTotalCrashesNum();
    
  • To reset the crashes counter, use the clearTotalCrashesNum() method:
  • 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();
            }
        }
    }
}
PREVIOUS
Use the crash callback
  NEXT
Disable network monitoring

This documentation applies to the following versions of Splunk MINT SDK for Android: 5.2.x


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters