This package includes classes, interfaces, and enumerations related to the TMD for our Android SDK.
Moprim TMD Android SDK requires to initialize the SDK first.
Initialization should happen as early as possible, and it requires connection to the Internet.
The easiest way to add the initialization code to an Application class.
import android.app.Application;
import android.content.Context;
import fi.moprim.tmd.sdk.TMD;
import fi.moprim.tmd.sdk.TmdCoreConfigurationBuilder;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TmdCoreConfigurationBuilder builder = new TmdCoreConfigurationBuilder(this)
.setSdkConfigEndPoint(getString(R.string.tmd_sdk_config_endpoint))
.setSdkConfigKey(getString(R.string.tmd_sdk_config_key));
// Initialise the TMD
TMD.init(this, builder.build(), new TmdInitListener() {
@Override
public void onTmdInitFailed(TmdError tmdError) {
Log.e(HelloWorldApplication.class.getSimpleName(), "Initialisation failed: " + tmdError.name());
}
@Override
public void onTmdInitSuccessful(String s) {
// s is the current installation ID, we'll put the UUID as the same just to demonstrate how to use the method
// replace with your own user id in production
TMD.setUUID(s);
// If you want to do trigger some process when the data is periodically uploaded to the cloud
Intent intent = new Intent(HelloWorldApplication.this, TmdUploadIntentService.class);
PendingIntent callbackIntent = PendingIntent.getService(HelloWorldApplication.this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
TmdCloudApi.setUploadCallbackIntent(callbackIntent);
}
});
}
}
Then you can start and stop the TMD at your own convenience:
You can set a unique identifier to the SDK for the user to allow the retaining of information after an application install with
setUUID(java.lang.String)
You can correct an activity label with
correctActivity(android.content.Context, fi.moprim.tmd.sdk.model.TmdActivity, java.lang.String)
Classes