Why keybaord does not show after tapping back on Android 10?

Issue

I have an Android Jetpack Compose project where I show a screen with a InputField:

  • When coming to that screen, the keyboard opens automatically, ready to read the users entered characters.
  • The screen also includes a "imprint" link opening default webbrowser

On Android 11 and higher, when I tap the back button (Android hardware button, triangle) the already opened webbrowser disappears and the previous input screen show again and the keyboard again opens automatically.

On Android 10 (emulator and real device), when I tap the back button (Android hardware button, triangle) the already opened webbrowser disappears and the previous input screen show again but the keyboard is not shown on Android 10.

Whats the reason for missing keyboard on Android 10?

Solution

Try using

val focusRequester = remember { FocusRequester() }
modifier = Modifier
        .focusRequester(focusRequester = focusRequester)

you can also use

LaunchedEffect(Unit) {
        focusRequester.requestFocus()
    }

Answered By – Nikhil Dupally

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published