Clipboard readtext not working in android webview

Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext function. It works just fine in mobile chrome, but in android webview, which is again based on chromium engine, it just does not work.

We have given all permission in android manifest

<uses-permission android:name="android.permission.READ_CLIPBOARD" />
<uses-permission android:name="android.permission.WRITE_CLIPBOARD" />
<uses-permission android:name="android.webkit.PermissionRequest" />
 ClipData clipData = clipboard.getPrimaryClip();
                    ClipData.Item item1 = clipData.getItemAt(0);
                    String text = item1.getText().toString();

webView.evaluateJavascript("(function(){document.activeElement.value = '"+text+"'})()",
                            new ValueCallback<String>() {
                                @Override
                                public void onReceiveValue(String value) {

                                }
                            });

But we are unable to get the paste menu on long press inside textarea just like whatsapp. Guide us as where we are going wrong.

1 Like

Corresponding tweet for this thread:

Share link for this tweet.