I want to change the text in a GoogleForm via Webview, however the action happens twice.
In the text box, it has the word twice, as if the javascript happens twice.
Would you have an idea? Thanks
public class QuestionnaireFragment extends Fragment {
//Lancement de l'activité
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_questionnaire, container, false);
WebView view = (WebView) rootView.findViewById(R.id.webview_questionnaire);
String url = "LINK GOOGLE FORMS";
WebSettings webSettings = view.getSettings();
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
view.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
String js ="javascript:document.getElementsByClassName(\"quantumWizTextinputPaperinputInput exportInput\")[0].focus(); document.execCommand('insertText', false, '" + "WORD"+ "');";
view.loadUrl(js);
}
});
return rootView;
}
}
EDIT : I change string by :
String js= "javascript:document.getElementsByClassName(\"quantumWizTextinputPaperinputInput exportInput\")[0].value=\"WORD\";";
But another probllem: