Activate a profile
To change the active configuration profile using SDK, call changeConfigProfile() on your PgManager reference with the following parameters:
PgCommandobject holding thePgConfigProfileand optionalPgCommandParams. The containingPgConfigProfilemust have a set profile name (profileId).The object implementing
IPgConfigProfileCallback. After the profile is successfully set (or in case of any errors), theIPgConfigProfileCallbackis called with the relevant information.
You can also broadcast an Intent with the following data:
Action:
com.proglove.api.CHANGE_CONFIG_PROFILEExtra: String in
com.proglove.api.extra.CONFIG_PROFILE_ID
Activation is successful if the profile with the specified ID exists in the configuration file.
val profileName: String = "myProfileToSet"
pgManager.changeConfigProfile(
PgCommand(PgConfigProfile(profileName)),
object : IPgConfigProfileCallback {
override fun onConfigProfileChanged(profile: PgConfigProfile) {
runOnUiThread {
Toast.makeText(
applicationContext,
"${profile.profileId} set successfully",
Toast.LENGTH_LONG
).show()
}
}
override fun onError(error: PgError) {
runOnUiThread {
Toast.makeText(
applicationContext,
"Failed to set $profileName - $error",
Toast.LENGTH_LONG
).show()
}
}
}
)val profileName: String = "myProfileToSet"
val intent = Intent()
intent.setAction("com.proglove.api.CHANGE_CONFIG_PROFILE")
intent.putExtra("com.proglove.api.extra.CONFIG_PROFILE_ID", profileName)
sendBroadcast(intent)Note
Explicit activation is only successful if the profile with the specified ID exists in the configuration file. Trying to replace an active profile with a non-existing profile ID using the SDK, returns an error. When changing it via Intent, there is no possibility to return an error.
Profiles can only be changed when Insight Mobile is running.