getIntent
fun getIntent(context: Context, appPackageName: String, @DrawableRes image: Int, topMessage: String, bottomMessage: String): Intent
Returns the Intent to display an install app prompt to the user.
This can be used in Compose with rememberLauncherForActivityResult and ActivityResultLauncher.launch:
val launcher = rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == RESULT_OK) {
// user pushed install!
}
}
launcher.launch(installAppPrompt.getIntent(/*params*/))
Content copied to clipboard
It can also be used directly in an ComponentActivity with ComponentActivity.registerForActivityResult:
val launcher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == RESULT_OK) {
// user pushed install!
}
}
launcher.launch(installAppPrompt.getIntent(/*params*/))
Content copied to clipboard