Splunk MINT SDK for Android (Legacy)

Splunk MINT SDK for Android Developer Guide

Splunk MINT is no longer available for purchase as of January 29, 2021. Customers who have already been paying to ingest and process MINT data in Splunk Enterprise will continue to receive support until December 31, 2021, which is End of Life for all MINT products: App, Web Service (Management Console), SDK and Add-On.

Use the crash callback

Use the MintCallback interface to debug your Splunk MINT SDK projects. The MintCallback interface provides two callback methods that give you more information about data that is being sent over the network or saved locally.

The SDK sends data over the network in the following cases:

  • When the app starts. The SDK sends a "hello" packet to update all of the real-time information that is displayed in the Splunk MINT dashboards, along with all of the information that was collected and saved from previous sessions.
  • When you explicitly call the Flush() method. The SDK sends all information that has been gathered and saved until that moment.
  • When an unexpected runtime exception occurs and crashes your app. The SDK collects the crash information and quickly informs you about that crash.
  • When batched event data reaches 140KB. The MINT SDK saves events in batches up to 140KB per file. If there is network connectivity, the SDK sends the data. Otherwise, the SDK continues to save up to three files of event data. If there is still no network connectivity, the SDK deletes the first file and continues saving data.


If the SDK can't complete the process of sending data over the network connection, the data is saved locally so that it can be sent the next time an active connection is available and the SDK initializes or you use the Flush() method.


The MintCallback interface has three callbacks that you can use to find out what is happening:

  • The dataSaverResponse callback function tells you when data is saved locally.
  • The netSenderResponse callback function tells you when data is sent over the network.
  • The lastBreath callback returns the exception that crashed your app.

Implement the MintCallback interface as follows:

public class MainActivity extends Activity implements MintCallback {
    ...
}

DataSaverResponse

Every time the SDK tries to save any information, the dataSaverResponse function is called with an object of the class DataSaverResponse as a parameter.

The DataSaverResponse contains information about the data that is saved, specifically the following fields:

// The data to save    
private String data;

// The path of the file
private String filepath;

// The exception if any, or null
private Exception exception;

// A Boolean indicating whether the data was saved successfully
private Boolean savedSuccessfully;

The following example shows a simple way to use the dataSaverResponse callback function:

public void dataSaverResponse(DataSaverResponse dsr) {
    Log.i("myapp", dsr.toString());
}

NetSenderResponse

Every time the SDK tries to send data over a network connection, the netSenderResponse function is called with an object of the class NetSenderResponse as a parameter.

The NetSenderResponse contains information about the data that is sent, specifically the following fields:

// The data to send
private String data;

// The URL of the server
private String url;

// The server's response
private String serverResponse;

// The server's response code
private int responseCode;

// The exception if any, or null
private Exception exception;

// A Boolean indicating whether the data was sent successfully
private Boolean sentSuccessfully;

The following example shows a simple way to use the netSenderResponse callback function:

public void netSenderResponse(NetSenderResponse nsr) {
    Log.i("myapp", nsr.toString());
}

LastBreath

The lastBreath callback function is called after a runtime exception occurs and before the application terminates, returning the exception as a parameter so that you can know exactly what went wrong.

Use the lastBreath callback as follows:

public void lastBreath(Exception exception) {
    ...
}

Note Be careful when using the lastBreath function because it blocks the thread while running.

Last modified on 28 January, 2019
Report user-specific data   Report the last error and total crashes

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


Was this topic useful?







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