All Apps and Add-ons

Splunk MINT: How to do determine if Mint.initAndStartSession() has already been called?

jf162
New Member

We have an Android app with numerous entry points: a main activity, a broadcast receiver for events, a job service for scheduling, a background service, an install referrer, etc.

What is the best way in each of these components to determine if Mint.initAndStartSession() has already been called?

The only way that we've found to do this so far is to use Mint.addExtraData() to add a key/value pair to Mint after calling initAndStartSession(), and to check for the existence of that key any time that we want to initialize Mint. The Java code sample below illustrates this technique.

Is there a better way to do this?

public static void initCrashReporting(Context appContext, String tag)
{
    HashMap<String, Object> map = Mint.getExtraData();
    if ((map != null) && map.containsKey(MINT_INITIALIZED)) {
        Log.d(tag, "Mint is already initialized");
    } else {
        Log.d(tag, "Mint is not initialized, doing so now...");
        Mint.initAndStartSession(appContext, MINT_APP_KEY);
        Mint.addExtraData(MINT_INITIALIZED, "xyz");
    }
}
0 Karma
1 Solution

croyal_splunk
Splunk Employee
Splunk Employee

We'd actually suggest that; it's the safest thing to do.

View solution in original post

0 Karma

croyal_splunk
Splunk Employee
Splunk Employee

We'd actually suggest that; it's the safest thing to do.

0 Karma
Get Updates on the Splunk Community!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...