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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...