See: Description
Class | Description |
---|---|
TMD |
Use this class to initialize the TMD
TMD.init(Context, TmdConfig) as soon as possible in your Application
subclass Application.onCreate() method. |
TmdCloudApi |
This class offers static functions to interact with the Moprim Cloud.
|
TmdConfig |
This class embodies the core variable that are needed to initiate any TMD processes
|
TmdConfig.Builder | |
TmdContentProvider |
The TmdContentProvider should enable access to
- TmdActivity data
- TmdStats data
- TmdStatus data (idle, etc..)
|
import android.app.Application; import android.content.Context; import fi.moprim.tmd.sdk.TMD; import fi.moprim.tmd.sdk.TmdConfigBuilder; public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); TmdConfigBuilder builder = new TmdConfigBuilder(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.setCallbackIntent(callbackIntent); } }); } }Then you can start and stop the TMD at your own convenience:
TMD.startForeground(android.content.Context, int, android.app.Notification)
TMD.stop(android.content.Context)
TMD.isTmdRunning(android.content.Context)
TmdCloudApi.correctActivity(android.content.Context, fi.moprim.tmd.sdk.model.TmdActivity, java.lang.String)