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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...