Class RunLearningUnitRequest
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 in Intent.getExtras().
Use getAssetAsStream(Context, String), getAssetAsFileDescriptor(Context, String), or getAssetAsUri(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 with toIntent(String, String).
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal LongOptional. The time of user inactivity after which the learning app must end the run withRunLearningUnitResult.ResultType.TimeoutInactivity.final StringThe obfuscated ID of the learner who is playing the learning unit.final StringAn ID, defined by the learning app, that uniquely identifies the learning unit to run.final StringA unique identifier of each learning unit run, which may be used for reporting purposes.final LongOptional. The maximum amount of time that this run may take.final StringThe obfuscated ID of the school at which the learning unit is being played.final StringIdentifies the stage of the EIDU app, e.g.final int -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic RunLearningUnitRequestfromIntent(Intent intent) Creates a new RunLearningUnitRequest instance from the provided intent.getAssetAsStream(Context context, String path) Retrieves the contents of an asset as anInputStream.getAssetAsUri(String path) Retrieves a contentUrifor an asset, which can be used, for example, withMediaPlayer.inthashCode()static RunLearningUnitRequestof(String learningUnitId, String learningUnitRunId, String learnerId, String schoolId, String stage, Long remainingForegroundTimeInMs, Long inactivityTimeoutInMs, Uri assetsBaseUri) Creates a new RunLearningUnitRequest instance.Creates an explicit intent usable to launch a learning app.
-
Field Details
-
version
public final int version -
learningUnitId
An ID, defined by the learning app, that uniquely identifies the learning unit to run. -
learningUnitRunId
A unique identifier of each learning unit run, which may be used for reporting purposes. -
learnerId
The obfuscated ID of the learner who is playing the learning unit. May be used for reporting purposes. -
schoolId
The obfuscated ID of the school at which the learning unit is being played. May be used for reporting purposes. -
stage
Identifies the stage of the EIDU app, e.g. "test", "prod". May be used for reporting purposes. -
remainingForegroundTimeInMs
Optional. The maximum amount of time that this run may take. The learning app must end the run withRunLearningUnitResult.ResultType.TimeUpafter this amount of foreground time has elapsed. -
inactivityTimeoutInMs
Optional. The time of user inactivity after which the learning app must end the run withRunLearningUnitResult.ResultType.TimeoutInactivity.
-
-
Method Details
-
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
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
InputStreamfrom 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
Retrieves a contentUrifor an asset, which can be used, for example, withMediaPlayer.At this point, it is not guaranteed that the
Uripoints to a valid asset.- Parameters:
path- The path of the asset to retrieve.- Returns:
- A
Urifrom which the asset's contents can be read. - Throws:
FileNotFoundException- In case the request does not support asset loading.
-
equals
-
hashCode
public int hashCode()
-