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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...