Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap for Android does not accept the 9 key

I have a strange problem in my PhoneGap-based android app. On certain screens, the number 9 key is completely ignored. This happens on all my Android 2.X devices. I have tried with previous versions of PG and found that the problem first occurred in v1.2.

Here is the code to a sample index.html file that should reproduce the issue. On both Android 2.2 and 2.3, the text boxes labeled as "broken" do not accept the number 9 as input.

    <!DOCTYPE html>
    <html>
    <head>
        <title>Test</title>
        <style>
        body
        {
            margin:0;
            padding:0;
            font-size:20px;
        }

        input
        {
            height:20px;
        }

        #container_second
        {
            overflow:hidden;
            position:relative;
            width:100%;
            height:150px;
        }

        #container_second div
        {
            left: -2000px;
            position: absolute;
            -webkit-transform: matrix(1, 0, 0, 1, 2000, 0);
        }
        </style>
    </head>
    <body>
        <br />
        <div id="container_first">
            <div>
                Working Text: <br /><input type="text" /><br /><br />
                Working Tel: <br /><input type="tel" />
            </div>
        </div>

        <br /><br />

        <div id="container_second">
            <div>
                Broken Text: <br /><input type="text" /><br /><br />
                Broken Tel: <br /><input type="tel" />
            </div>
        </div>
    </body>
    </html>
like image 230
jmsgofish Avatar asked Mar 20 '12 05:03

jmsgofish


2 Answers

It might be related to this issue. For some reason PhoneGap is calling setNavDump on the web view's WebSettings. setNavDump is an obsolete method according to the android docs so you should be fine if you disable it.

One way to do it is by overriding the init method in your class that extends DroidGap

    @Override
public void init() {
    super.init();       
    this.appView.getSettings().setNavDump(false);
}

If that doesn't work, try adding it after the loadUrl call in the existing onCreate method:

@Override
public void onCreate(Bundle savedInstanceState) {
    //... snip ...
    super.loadUrl("file:///android_asset/www/index.html", 12000);
    this.appView.getSettings().setNavDump(false);
    //... snip ...
}
like image 140
Jason Freitas Avatar answered Oct 20 '22 16:10

Jason Freitas


I had the same issue. Turns out that you need to specify the Android SDK version via the API number in the config.xml file

add: <preference name="android-minSdkVersion" value="8" />

like image 30
Jamie Kovach Avatar answered Oct 20 '22 15:10

Jamie Kovach