I have warning in closed testing, i have implement splash screen API in my project, but play store always detected double splash screen in android 12 or higher.
Please help me to fix this problem
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val viewModel by viewModels<MainLayoutViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
val splashScreen = installSplashScreen()
super.onCreate(savedInstanceState)
var keepSplashScreenOn = viewModel.isLoading.value
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.isLoading.collect {
keepSplashScreenOn = it
}
}
}
splashScreen.setKeepOnScreenCondition {
keepSplashScreenOn
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannelManager.apply {
createNotificationChannelFCM(applicationContext)
createNotificationChannelTest(applicationContext)
}
}
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
SmartcubeAppTheme {
val startDestination by viewModel.startDestination.collectAsStateWithLifecycle()
startDestination?.let {
Box(Modifier.safeDrawingPadding()) {
MainLayout(
initialScreen = it
)
}
}
}
}
}
}
@HiltViewModel
class MainLayoutViewModel @Inject constructor(
private val tokenAppRepositoryImpl: ITokenAppRepository
) : ViewModel() {
private val _startDestination = MutableStateFlow<String?>(null)
val startDestination: StateFlow<String?> = _startDestination
val isLoading: MutableStateFlow<Boolean> = MutableStateFlow(true)
init {
getFlowToken()
}
private fun getFlowToken() {
viewModelScope.launch {
delay(3000)
tokenAppRepositoryImpl.getFlowAccessToken().collect {
when (it) {
is SessionState.Loading -> Unit
is SessionState.Empty -> {
isLoading.value = false
_startDestination.value = Screen.Login.screenRoute
}
is SessionState.Exist -> {
isLoading.value = false
_startDestination.value = Screen.Dashboard.screenRoute
}
}
}
}
}
}
please correct my code, i got stuck in here
playstore not detected double splash screen in android 12 or higher
New contributor
Iqbal Maulana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.