2

I have the corollary question to my first (solved) question, SO Android show softkeybard ...

With the sliding keyboard closed, I want my activity to show the keyboard when it gets started.

The same manifest should apply with "stateVisible" set in the manifest for my activity. Do I need any explicit code with the InputMethodManger? Again, I have experimented with the obvious methods and flags, but it does not open the keyboard on the phones with sliding keyboards.

The manifest is copied here for convenience:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mycompany.android.studyIme"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".StudyImeActivity"
                  android:label="@string/app_name" 
                  android:windowSoftInputMode="stateAlwaysVisible|stateVisible">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>
Community
  • 1
  • 1
mobibob
  • 8,670
  • 20
  • 82
  • 131

1 Answers1

-1

My colleague solved the issue. Instead of trying to force-show, she demonstrated the solution with the "toggle" method.

 InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); 
 imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); 

Of course, you might want to wrap this inside a configuration check of the state of the keyboard.

mobibob
  • 8,670
  • 20
  • 82
  • 131