Copy Paste Not Working in android webview?

Viewed 564

I'm trying to copy-paste inside my webview but it is not allowing me to paste any content inside the android webview textbox.

Following is common code that I have used in order to work with web view, I have also tried checking solutions on another question asked in StackOverflow but unable to find a proper solutions.

WebView mWebview;
mWebview = findViewById(R.id.webViewPreview);
mWebview.setWebViewClient(new myWebClient());
mWebview.getSettings().setJavaScriptEnabled(true);
mWebview.loadUrl(url);


mWebview.setOnKeyListener(new View.OnKeyListener() {

            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK
                        && event.getAction() == MotionEvent.ACTION_UP
                        && mWebview.canGoBack()) {
                    return true;
                }

                return false;
            }

        });

if (Build.VERSION.SDK_INT >= 19) {
            mWebview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        } else if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT < 19) {
            mWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }

public class myWebClient extends WebViewClient {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            if (pd != null) {
                pd.show();
            }
            Log.d("WebView", "your current url when webpage loading.." + url);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            //view.loadUrl(url);
            Log.v("shouldOverride", "shouldOverrideUrlLoading");
            System.out.println("UPDATED URL :-" + url);
            return false;
        }


        @Override
        public void onPageFinished(WebView view, String url) {
            Log.d("WebView", "your current url when webpage loading.. finish" + url);
            if (pd != null) {
                pd.dismiss();
            }
            super.onPageFinished(view, url);
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onLoadResource(view, url);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode,
                                    String description, String failingUrl) {
            //Log.e("ERROR", "Error occured while loading the web page at Url" + failingUrl + "." + description);
            view.loadUrl("about:blank");

            linearNotFound.setVisibility(View.VISIBLE);
            mWebview.setVisibility(View.GONE);
            super.onReceivedError(view, errorCode, description, failingUrl);
        }

    }

This above code not allowing me to paste the content inside webview textbox, What are changes I have to implement in order to enable copy-paste in webview controls.

0 Answers
Related