1

I need to detect hidden key board when hidden keyboard is pressed
My source code

<activity
    android:name="com.teamios.info.activity.MainScreenActivity"
    android:screenOrientation="landscape"
    android:theme="@style/Theme.MyScreenTranNorman"
    android:configChanges="orientation|keyboardHidden"
    android:windowSoftInputMode="stateUnchanged|adjustPan" />

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
}

I tested in samsung galaxy nexus phone android os 4.2.1, but Toast didn't show when keyboard hidden Please help me.

wind
  • 63
  • 1
  • 3
  • 9
  • try this code Toast.makeText(MainActivity.this, "keyboard visible 1", Toast.LENGTH_SHORT).show(); – ADT Sep 11 '13 at 07:42
  • The problem is when keyboard show/hide then onConfigurationChanged function isn't called – wind Sep 11 '13 at 08:28
  • I'm having this same issue on Android 4.4.4 (Cyanogenmod) for an S4 (GT-i9505G). I have an identical phone running 5.0 (Google Play Edition) and it gets the onConfigurationChanged() call just fine. On the 4.4.4 device, the keyboard actually connects and can type characters into my app, but the app is not informed when attachment occurs. May be an OS bug. – Carl Jun 08 '15 at 08:31

2 Answers2

1
 <activity
        android:name="com.teamios.info.activity.MainScreenActivity"
        android:theme="@style/Theme.MyScreenTranNorman"
        android:configChanges="orientation|keyboardHidden"
        android:windowSoftInputMode="stateUnchanged|adjustPan" />

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
        Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
    } else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
        Toast.makeText(this, "keyboard hidden", Toast.LENGTH_SHORT).show();
    }
    }

And add

<activity android:name=".MyActivity" android:screenOrientation="landscape " > </activity>

in menifest class.

John R
  • 2,078
  • 8
  • 35
  • 58
0

Did you add android:configChanges="keyboardHidden" in your manifest file ?

user1764879
  • 112
  • 1
  • 9
  • Yes, I did. In manifest i config below android:configChanges="orientation|keyboardHidden" – wind Sep 11 '13 at 08:50