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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

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