diff --git a/datalayer/phone-ui/src/main/java/com/google/android/horologist/datalayer/phone/ui/prompt/installapp/InstallAppBottomSheetActivity.kt b/datalayer/phone-ui/src/main/java/com/google/android/horologist/datalayer/phone/ui/prompt/installapp/InstallAppBottomSheetActivity.kt index 5a7efd44b7..a7bbbd3e18 100644 --- a/datalayer/phone-ui/src/main/java/com/google/android/horologist/datalayer/phone/ui/prompt/installapp/InstallAppBottomSheetActivity.kt +++ b/datalayer/phone-ui/src/main/java/com/google/android/horologist/datalayer/phone/ui/prompt/installapp/InstallAppBottomSheetActivity.kt @@ -27,8 +27,10 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Surface import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.res.painterResource import com.google.android.horologist.datalayer.phone.ui.play.launchPlay +import kotlinx.coroutines.launch internal const val INSTALL_APP_KEY_APP_NAME = "HOROLOGIST_INSTALL_APP_KEY_APP_NAME" internal const val INSTALL_APP_KEY_APP_PACKAGE_NAME = "HOROLOGIST_INSTALL_APP_KEY_APP_PACKAGE_NAME" @@ -53,6 +55,7 @@ internal class InstallAppBottomSheetActivity : ComponentActivity() { setContent { Surface { val installAppBottomSheetState = rememberModalBottomSheetState() + val coroutineScope = rememberCoroutineScope() val icon: (@Composable () -> Unit)? = imageResId.takeIf { it != NO_IMAGE }?.let { { @@ -70,7 +73,13 @@ internal class InstallAppBottomSheetActivity : ComponentActivity() { icon = icon, onDismissRequest = { setResult(RESULT_CANCELED) - finish() + coroutineScope.launch { + try { + installAppBottomSheetState.hide() + } finally { + finish() + } + } }, onConfirmation = { this.launchPlay(appPackageName)