Package fi.moprim.tmd.sdk
Class TMD
- java.lang.Object
-
- fi.moprim.tmd.sdk.TMD
-
public final class TMD extends java.lang.ObjectUse this class to initialize the TMDinit(Context, TmdConfig)as soon as possible in yourApplicationsubclassApplication.onCreate()method.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.StringgetInstallationId()Retrieve the unique application installation id of application using the SDKstatic TMDgetInstance()android.app.PendingIntentgetStartCallbackIntent()Deprecated.since v.0.5.0java.lang.Class<? extends androidx.work.ListenableWorker>getStartCallbackWorkerClass()java.lang.StringgetUUID(android.content.Context context)voidinit(android.content.Context applicationContext, TmdConfig tmdConfig)Initialize Moprim TMD for a given Application.booleanisConfigured(android.content.Context context)Returns true if the TMD was able to receive the configuration from the CloudbooleanisInitialized()static booleanisTmdRunning(android.content.Context context)voidsetStartCallbackIntent(android.app.PendingIntent intent)Deprecated.since v.0.5.0voidsetStartCallbackWorkerClass(android.content.Context context, java.lang.Class<? extends androidx.work.ListenableWorker> startCallbackWorkerClass)Sets an callback worker for the background start of the TMD.voidsetUUID(android.content.Context context, java.lang.String uuid, OnSetUUIDListener listener)Set an unique user id to gather data from multiple installations.static TmdStartReturnCodestartForeground(android.content.Context context, int id, android.app.Notification notification)Starts the TMD service for the given contextstatic voidstop(android.content.Context context)Stops the TMD servicestatic voidstop(android.content.Context context, boolean fromUserAction)Stops the TMD servicevoidtestInit(android.content.Context applicationContext, TmdConfig coreConfiguration)static booleanwasTmdStarted(android.content.Context context)
-
-
-
Method Detail
-
getInstance
public static TMD getInstance()
-
setStartCallbackIntent
@Deprecated public void setStartCallbackIntent(android.app.PendingIntent intent)
Deprecated.since v.0.5.0Sets an callback intent for the background start of the TMD.- Parameters:
intent- the intent to be executed
-
getStartCallbackIntent
@Deprecated public android.app.PendingIntent getStartCallbackIntent()
Deprecated.since v.0.5.0- Returns:
- the callback that will be called during background start of the TMD
-
setStartCallbackWorkerClass
public void setStartCallbackWorkerClass(@NonNull android.content.Context context, @Nullable java.lang.Class<? extends androidx.work.ListenableWorker> startCallbackWorkerClass)Sets an callback worker for the background start of the TMD.- Parameters:
startCallbackWorkerClass- the class of the job to start the TMD from background
-
getStartCallbackWorkerClass
@Nullable public java.lang.Class<? extends androidx.work.ListenableWorker> getStartCallbackWorkerClass()
-
init
public void init(@NonNull android.content.Context applicationContext, TmdConfig tmdConfig)Initialize Moprim TMD for a given Application.
The call to this method should be placed as soon as possible in theApplication.onCreate()method.- Parameters:
applicationContext- Your Application context.- Throws:
java.lang.IllegalStateException- if it is called more than once.
-
testInit
public void testInit(@NonNull android.content.Context applicationContext, TmdConfig coreConfiguration)
-
startForeground
public static TmdStartReturnCode startForeground(@NonNull android.content.Context context, int id, android.app.Notification notification)
Starts the TMD service for the given context- Parameters:
context- the given context
-
stop
public static void stop(@NonNull android.content.Context context)Stops the TMD service- Parameters:
context- the context to stop the tmd service
-
stop
public static void stop(@NonNull android.content.Context context, boolean fromUserAction)Stops the TMD service- Parameters:
context- the context to stop the tmd servicefromUserAction- tells if the stop was coming from a user action (TMD will not restart automatically)
-
isTmdRunning
public static boolean isTmdRunning(@NonNull android.content.Context context)- Parameters:
context- the context- Returns:
- true if the TMD service for this app is already running
-
wasTmdStarted
public static boolean wasTmdStarted(@NonNull android.content.Context context)- Parameters:
context- the context- Returns:
- true if the TMD service for this app was started
-
getInstallationId
@WorkerThread public java.lang.String getInstallationId()
Retrieve the unique application installation id of application using the SDK- Returns:
- public static String getUUID() { return null; }the unique installation id
-
getUUID
public java.lang.String getUUID(@NonNull android.content.Context context)
-
setUUID
public void setUUID(@NonNull android.content.Context context, java.lang.String uuid, OnSetUUIDListener listener)Set an unique user id to gather data from multiple installations. This identifier may have the side effect to disable data collection from former installations TODO Enable the registration via a separate API in the cloud- Parameters:
context- the context of the applicationuuid- the uuidlistener- Listener to see if the UUID can be set for this installation
-
isInitialized
public boolean isInitialized()
- Returns:
- true if the TMD has been properly initialized
-
isConfigured
public boolean isConfigured(@NonNull android.content.Context context)Returns true if the TMD was able to receive the configuration from the Cloud- Returns:
- true is the configuration was obtained from the Cloud for the identified user
-
-