Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Phonegap SoftKeyboard Plugin for Android?

Tags:

I am developing an Android application using Phonegap. I need to make the softkeyboard appear programatically. I am using the SoftKeyboard plugin which is found here. Can anyone tell me how to properly include this plugin & make it work? I have tried the tutorial found on the Phonegap Wiki, but the plugin is not working.

[Update] I have added the plugin to the path

com/zenexity/SoftKeyBoardPlugin/SoftKeyBoard.java

Updated plugins.xml and included

<plugin name="SoftKeyBoard" value="com.zenexity.SoftKeyBoardPlugin.SoftKeyBoard"/> 

Then in the www folder added softkeyboard.js, and the following in index.html

plugins.SoftKeyBoard.show(function () {     // success },function () {    // fail }); 

But nothing happens, the keyboard is not displaying..

like image 909
nbk Avatar asked Jan 30 '12 07:01

nbk


1 Answers

This is how I got SoftKeyBoard working in my application.

DroidGap Side

  • create /src/com/phonegap/plugins/SoftKeyboard with provided file SoftKeyBoard.java inside
  • add to /res/xml/plugins.xml:

    < plugin name="SoftKeyBoard" value="com.phonegap.plugins.SoftKeyboard.SoftKeyBoard" />

/assets/www Side

  • add provided file softkeyboard.js to /assets/www/js
  • add to index.html in the head where your other javascripts are included after you have included the phonegap javascript:

    < script type="text/javascript" charset="utf-8" src="js/softkeyboard.js"></script>

You can then call the following if you are on device or using something like Ripple:

window.plugins.SoftKeyBoard.show(function () {   // success },function () {   // fail }); 

or something like this if you want to make sure the namespace is available, which will prevent undefined problems:

((((window || {}).plugins || {}).SoftKeyBoard || {}).show || function(){})(); 

I think maybe where you went wrong was not including the js/softkeyboard.js in your head of index.html.

Hope this helps you

like image 162
darryn.ten Avatar answered Nov 12 '22 22:11

darryn.ten