Auto click on WebView - android

How can I perform click on WebView from java code? Is it possible to click on a specified location (x,y)?
WebView.performClick()
doesn't work!

You can do this by injecting javascript to your webview using loadUrl():
mWebView.loadUrl("javascript:<your javascript here>");
This example code will perform a click on the element with id 'button_submit':
mWebView = new WebView(context);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("javascript:getElementById('button_submit').click();");

Related

Android Webview doesn't load

I have a problem with Android Web view.
The slider work fine with Apple but doesn't load on Android WebView.
Can anyone help? www.pgc-usa.net/ivynails
Thanks
I think I know. Web views in Android by default do not have JavaScript enabled. This is because there is someway it can do harm to the app. To enable it though it takes two lines
WebSettings webSettings = yourWebview.getSettings();
yourWebview.setJavaScriptEnabled(true);
You can also set it so that links that are clicked open in the web view. ( Otherwise they open in browser.) to add this you just add
yourWebview.setWebViewClient(new WebViewClient());
All that together will make it come to this:
WebView yourWebview = (WebView) findViewById(R.id.myWebview);
yourWebview.loadUrl("http://www.pgc-usa.net/ivynails");
WebSettings webSettings = yourWebviewgetSettings();
webSettings.setJavaScriptEnabled(true);
yourWebview.setWebViewClient(new WebViewClient());
You can find out more by visiting this page on the Android developer site by clicking this link.

how to fetch a page link and get open it inside phone browser, on user click (Android)

i wonder how to get address of a page inside of a web view on user click, and take that address and open it inside phone browser. for example let's say i open google inside a web view and when i click on one of the links from search then i want to fetch that link and get open it inside phone browser. the code for the web view is as follows:
myWebView = (WebView) findViewById(R.id.webView1);
myWebView.setWebViewClient(new WebViewClient());
myWebView .getSettings().setJavaScriptEnabled(true);
myWebView .getSettings().setDomStorageEnabled(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setSupportZoom(false);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.loadUrl("http://www.google.com/");
you can inject javascript that will find the link and call function from your java activity with android java bridge like How to call javascript from Android?

Android Webview for videosteams?

I am using a webview to connect to an ip camera. It works when I need snapshots , but i get a white screen when I try to get videostreams. I tried .getPlugins as well. What could be the possible reason?
mWebView = (WebView) findViewById(R.id.webView1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://<ipaddress>/videostream.cgi?user=&pwd=");
you can call Browser activity and set specific URL by intent. Take a look here: Sending an Intent to browser to open specific URL

Force webview to open urls inside application - android app

How to force WebView to open all the urls inside the application?
You need to override the WebViewClient for your WebView.
See here for the details: it's pretty straight forward.
Notice Step 6 in particular.
To open links clicked by the user, simply provide a WebViewClient for
your WebView, using setWebViewClient(). For example:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
That's it. Now all links the user clicks load in your WebView.

Internal links in WebView

I want to find out when a user clicks an internal link in a url currently opened in webview. How can I do that?
Thanks,
Farha
Try setting WebViewClient for the WebView and the onPageStarted() method will be called when the page loading is started.
Edit:
To be more clear, this may be a sample code:
WebView wview = (WebView) findViewById(R.id.webView1);
WebViewClient wvClient = new WebViewClient();
wview.setWebViewClient(wvClient);
wvClient.onPageStarted(wview, wview.getUrl(), null);

Categories

Resources