Class RunLearningUnitRequest
- java.lang.Object
-
- com.eidu.integration.RunLearningUnitRequest
-
public final class RunLearningUnitRequest extends Object
A RunLearningUnitRequest is what the EIDU app uses to launch a learning unit from integrated learning apps.The EIDU app will send an intent to your app, identified by the intent action (See
Intent.setAction(String)
) and include all data relevant for you to identify the learning unit to run.The intent sent also includes references to the learner and their school.
The easiest way to obtain the data provided by the Intent sent from EIDU is
fromIntent(Intent)
, which will automatically identify and extract all information included inIntent.getExtras()
.Use
getAssetAsStream(Context, String)
,getAssetAsFileDescriptor(Context, String)
, orgetAssetAsUri(String)
to retrieve any assets required by the requested learning unit.To facilitate testing of your app, you can create your own RunLearningUnitRequest with
of(String, String, String, String, String, Long, Long, Uri)
and convert it to an Intent withtoIntent(String, String)
.
-
-
Field Summary
Fields Modifier and Type Field Description Long
inactivityTimeoutInMs
Optional. The time of user inactivity after which the learning app must end the run withRunLearningUnitResult.ResultType.TimeoutInactivity
.String
learnerId
The obfuscated ID of the learner who is playing the learning unit.String
learningUnitId
An ID, defined by the learning app, that uniquely identifies the learning unit to run.String
learningUnitRunId
A unique identifier of each learning unit run, which may be used for reporting purposes.Long
remainingForegroundTimeInMs
Optional. The maximum amount of time that this run may take.String
schoolId
The obfuscated ID of the school at which the learning unit is being played.String
stage
Identifies the stage of the EIDU app, e.g.int
version
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static RunLearningUnitRequest
fromIntent(Intent intent)
Creates a new RunLearningUnitRequest instance from the provided intent.InputStream
getAssetAsStream(Context context, String path)
Retrieves the contents of an asset as anInputStream
.Uri
getAssetAsUri(String path)
Retrieves a contentUri
for an asset, which can be used, for example, withMediaPlayer
.int
hashCode()
static RunLearningUnitRequest
of(String learningUnitId, String learningUnitRunId, String learnerId, String schoolId, String stage, Long remainingForegroundTimeInMs, Long inactivityTimeoutInMs, Uri assetsBaseUri)
Creates a new RunLearningUnitRequest instance.Intent
toIntent(String packageName, String className)
Creates an explicit intent usable to launch a learning app.
-
-
-
Field Detail
-
version
public final int version
-
learningUnitId
@NonNull public final String learningUnitId
An ID, defined by the learning app, that uniquely identifies the learning unit to run.
-
learningUnitRunId
@NonNull public final String learningUnitRunId
A unique identifier of each learning unit run, which may be used for reporting purposes.
-
learnerId
@NonNull public final String learnerId
The obfuscated ID of the learner who is playing the learning unit. May be used for reporting purposes.
-
schoolId
@NonNull public final String schoolId
The obfuscated ID of the school at which the learning unit is being played. May be used for reporting purposes.
-
stage
@NonNull public final String stage
Identifies the stage of the EIDU app, e.g. "test", "prod". May be used for reporting purposes.
-
remainingForegroundTimeInMs
@Nullable public final Long remainingForegroundTimeInMs
Optional. The maximum amount of time that this run may take. The learning app must end the run withRunLearningUnitResult.ResultType.TimeUp
after this amount of foreground time has elapsed.
-
inactivityTimeoutInMs
@Nullable public final Long inactivityTimeoutInMs
Optional. The time of user inactivity after which the learning app must end the run withRunLearningUnitResult.ResultType.TimeoutInactivity
.
-
-
Method Detail
-
of
@NonNull public static RunLearningUnitRequest of(@NonNull String learningUnitId, @NonNull String learningUnitRunId, @NonNull String learnerId, @NonNull String schoolId, @NonNull String stage, @Nullable Long remainingForegroundTimeInMs, @Nullable Long inactivityTimeoutInMs, @Nullable Uri assetsBaseUri)
Creates a new RunLearningUnitRequest instance.Use this to test your learning app against what the EIDU app will send to launch a learning unit.
- Parameters:
learningUnitId
- Required, seelearningUnitId
.learningUnitRunId
- Required, seelearningUnitRunId
.learnerId
- Required, seelearnerId
.schoolId
- Required, seeschoolId
.stage
- Required, seestage
.remainingForegroundTimeInMs
- Optional, seeremainingForegroundTimeInMs
.inactivityTimeoutInMs
- Optional, seeinactivityTimeoutInMs
.assetsBaseUri
- Optional, the base content URI from which to retrieve assets.- Returns:
- The new instance.
-
fromIntent
@Nullable public static RunLearningUnitRequest fromIntent(@NonNull Intent intent) throws IllegalArgumentException
Creates a new RunLearningUnitRequest instance from the provided intent.Use this on the intent sent to your learning app by EIDU to get access to the necessary data.
- Parameters:
intent
- Required, the intent sent from the EIDU app to your learning app.- Returns:
- The new RunLearningUnitRequest instance, initialized from the provided intent, or null if intent was not a request to run a learning unit
- Throws:
IllegalArgumentException
- If the provided intent does not contain all required data.
-
toIntent
@NonNull public Intent toIntent(@NonNull String packageName, @NonNull String className)
Creates an explicit intent usable to launch a learning app.You can use this method, along with
of(String, String, String, String, String, Long, Long, Uri)
to test your app.- Parameters:
packageName
- The package name of the learning app.className
- The class name of the activity to launch with this intent- Returns:
- An intent for the given package and class, containing all the launch information.
-
getAssetAsStream
@NonNull public InputStream getAssetAsStream(@NonNull Context context, @NonNull String path) throws FileNotFoundException
Retrieves the contents of an asset as anInputStream
. It is the caller's responsibility to close this stream after use.- Parameters:
context
- The current context. May be an application context.path
- The path of the asset to retrieve.- Returns:
- An
InputStream
from which the asset's contents can be read. - Throws:
FileNotFoundException
- In case an asset by that name cannot be found for the learning unit being run, the request does not support asset loading, or EIDU has crashed.
-
getAssetAsUri
@NonNull public Uri getAssetAsUri(@NonNull String path) throws FileNotFoundException
Retrieves a contentUri
for an asset, which can be used, for example, withMediaPlayer
.At this point, it is not guaranteed that the
Uri
points to a valid asset.- Parameters:
path
- The path of the asset to retrieve.- Returns:
- A
Uri
from which the asset's contents can be read. - Throws:
FileNotFoundException
- In case the request does not support asset loading.
-
-