Home > other >  Android Tenjin SDK Integration
Android Tenjin SDK Integration

Time:12-10

Can you tell me please, did anyone work with Tenjin? Trying to connect it to android app: https://docs.tenjin.com/en/send-events/android.html#integration. They have this phrase in their dock on connection:

NOTE: Please make sure you implement this code on every onResume, not only on the first app open of the app. If we notice that you don't follow our recommendation, we can't give you proper support or your account might be suspended.

It means this code

TenjinSDK instance = TenjinSDK.getInstance(this, "<API_KEY>");
instance.connect();

I really need to stuff it into every onResume(), i.e. into every class and fragment that I have, or have I misunderstood something?

CodePudding user response:

You can create a sample base class or Application class and use it in your activities.

CodePudding user response:

Make a base Activity class like:

class BaseActivity : AppCompatActivity() {

   // keep non private to access the variable in subclasses.
   val tenjinInstance by lazy { TenjinSDK.getInstance(this, "<API_KEY>"); }

    override fun onResume() {
        super.onResume();
        instance.connect();
    }
}

And then make all your Activities extend BaseActivity like:

class MainActivity : BaseActivity() {
    // no need to use connect anywhere now.
}
  • Related