singleCursorHandlerTouchEvent -getEditableSupport

2019-04-10 04:27发布

问题:

I have a webview in my app. there is a browse(to upload files) button in a web page. When I test the app in HTC (Android 4.0.3) it is working but in Galaxy S3 (Android 4.1.1) it's not working.

I won't get the file chooser menu. Apparently button is not clickable instead when I touch anywhere of the screen I get

"singleCursorHandlerTouchEvent -getEditableSupport FASLE".

I have tried all the posible solutions.

    // Profile web view
    mWebView = (WebView) findViewById(R.id.itemWebView);
    //improve the speed
    mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSupportZoom(false);
    //setup the file chooser
    mWebView.setWebChromeClient(new WebChromeClient() {
        public void openFileChooser(ValueCallback<Uri> uploadMsg) {  

            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("image/*");
            ProfileActivity.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"),FILECHOOSER_RESULTCODE);
        }

        @SuppressWarnings("unused")
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg);
        }

        @SuppressWarnings("unused")
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg);
        } 

    });

This is my onActivityResult function

protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    if (requestCode == FILECHOOSER_RESULTCODE) {
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != RESULT_OK ? null
                : intent.getData();
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    } else {
        System.out.println("Something else->" + requestCode);
    }
}

In my jQuery mobile webpage I have a simple form:

<form id="edit" method="post" enctype="multipart/form-data" data-ajax="false" action = "profile_myimage.php">
            <div data-role="fieldcontain">
                <label for="image" class="required">Select photo</label>
                <input type="file" name="image" id="image" />
                <p class="error_message" id="img"><p>
            </div>

Please help me to fix this. I appreciate your support.

回答1:

I just had this same issue, and the problem (only seems to be on Android 2.x.x) for me was that the WebView does not receive focus.

You can do this to request focus on your WebView when a touch is received:

webView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent event) {
        if(event.getAction() == MotionEvent.ACTION_DOWN && !view.hasFocus()) {
            view.requestFocus();
        }
        return false;
    }
});

See android WebView - content not editable



回答2:

I ran into the same problem developing an app with a WebViewClient and a form. Turns out the solution is to make your input bigger (make sure it isn't overflowing)

My HTML layout was

<form>
  <div>
    <input type="text" onclick="..." />
    <span>...</span>
  </div>
</form>

With some sizing CSS applied to the elements. The parent div had overflow:hidden on it, so the input element had a scrollbar when you viewed the page in a browser. Fixing this made the onclick start firing correctly again, and made the input selectable from the android app.

Take a look at this question (helped me figure this out): Phonegap button does not fire due to "singleCursorHandlerTouchEvent -getEditableSupport FASLE"



回答3:

I had a similar issue: singleCursorHandlerTouchEvent -getEditableSupport FASLE

It seems that android (on samsung s3 mini) didn't like that there was a scrollbar in the div element that contained the button for file input.

This is what I had:

<div style ="overflow: auto; white-space: nowrap;" class="panel-body commentForm" />

And this is how it works now:

<div class="panel-body commentForm" />