Android Keyboard Tutorial [English]

[Objectives of Producing the plugin]

TouchScreenKeyboard provided by Unity is more limited than Android Native SoftKeyboard. When composing characters, ‘Input.compositionString’ does not work well, , as does ‘TouchScreenKeyboard.hideInput’.

I have written this plugin so we can be free from those constraints. In addition, option “adjustResize” is included.

 

[Requirements]

 Unity 4.6.3 or higher

NGUI 3.5.0 or higher

Android Minimum API Level: 9 (Android 2.3.1 Gingerbread)

 

[Create or modify AndroidMenifest.xml ]

  1. If you have AndroidMenifest.xml, add the code below

<activity

           android:name=com.OhYeahDev.softInput.KeyboardActivity

           android:configChanges=orientation|fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen

           >

</activity>

 

  1. If you don’t have “Main Activity”, insert the code below inside the code upper.

 <intent-filter>

          <action android:name=android.intent.action.MAIN />

          <category android:name=android.intent.category.LAUNCHER />

        </intent-filter>

      </activity>

  

  1. If you don’t have AndroidMenifest.xml, copy Sample_AndroidManifest.xml to “Assets/Plugins/Android” and remove “Sample_” on the file name.

 

 

[Activate the activity]

Right after your application has run, you must call

AndroidKeyboardManager.Install()” method.  

 

 

[Open the keyboard and setting options]

  1. Use the namespaces on the script

  1. Use the way of TouchScreenKeyboard that Unity provides

 

[Additional options]

  1. fullScreen
  • Only works in landscape mode
  • Show keyboard in full-screen mode

half screen

 

  1. No Suggestions
  • Removes “Suggestion Words” Bar up on the keyboard

* This option doesn’t work on certain hardware.

* Only works in landscape mode

 


  1. SoftInputMode
  • InputAdjustType.SOFT_INPUT_ADJUST_RESIZE 

 Raises the screen up on the keyboard

  • InputAdjustType.SOFT_INPUT_ADJUST_PAN 

 Contrary to the above, this raises the keyboard with the screen fixed

 

  4. KeepKeyboardOn

  • AdditionalOptions.keepKeyboardOn = true;
  • Keyboard is not hidden when the “Done” button is clicked

 

 

[Advanced options]

  1. Add flags and masks (Please refer to InputType.cs)

 

 

[Compatibility for NGUI]         

  1. Unzip “Assets/Plugins/Android/AndroidKeyboard/NGUI Ver/UIInput.zip” and overwrite it on the existing one
  • We have the files for NGUI 3.8.0, 3.9.0 (now in summer 2015)
  • All options must be completed before opening the keyboard (hideInput, softInputMode, Nosuggestion and fullScreen)
  • In case of hideInput, please take notice of the code below.

 

  1. Try testing compatibility for NGUI by installing InputTest_NGUI.apk

 

[Example Scenes]

Test_Landscape, Test_Portrait scenes have been created to try testing the functions of the keyboard

  • hideInput has no cursor and “Selection” is not possible because we created this for test.

     

     


 

Posted in Tutorials

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>