admin管理员组文章数量:1415139
We built a hybrid application using android webview and I use my phone (LG Nexus 4) to test it. The android application used to show JavaScript alerts from the website properly earlier but lately it has stopped showing the same.
It is throwing the following error whenever an alert is to be thrown from the application and nothing is shown.
Cannot create a dialog, the WebView context is not an Activity
I am suspecting that this behaviour has started after google has recently updated the WebView ponent. I am right now running on Android 5.0.1 and webview version is 40 (1832189-arm)
I will try rolling back the updates and check but I can't ask all the users to do it. Are there any other issues reported similar to this? Is there a solution?
Update I have uninstalled the updates to the WebView ponent and checked. Alerts are being shown fine. If this is an issue, where can I report it?
We built a hybrid application using android webview and I use my phone (LG Nexus 4) to test it. The android application used to show JavaScript alerts from the website properly earlier but lately it has stopped showing the same.
It is throwing the following error whenever an alert is to be thrown from the application and nothing is shown.
Cannot create a dialog, the WebView context is not an Activity
I am suspecting that this behaviour has started after google has recently updated the WebView ponent. I am right now running on Android 5.0.1 and webview version is 40 (1832189-arm)
I will try rolling back the updates and check but I can't ask all the users to do it. Are there any other issues reported similar to this? Is there a solution?
Update I have uninstalled the updates to the WebView ponent and checked. Alerts are being shown fine. If this is an issue, where can I report it?
Share Improve this question asked Apr 16, 2015 at 11:43 Pavan AndhukuriPavan Andhukuri 1,6173 gold badges27 silver badges49 bronze badges 4- dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.show(); – Rahul Commented Apr 16, 2015 at 11:48
- I think you have to report on play store. – Hareshkumar Chhelana Commented Apr 16, 2015 at 11:48
- @Rah, and "dialog" is? – Pavan Andhukuri Commented Apr 16, 2015 at 11:51
- AlertDialog for onJsAlert. – Rahul Commented Apr 16, 2015 at 12:31
3 Answers
Reset to default 4To get JavaScript Alert to work on Android WebView add below line of code:
mWebView.setWebChromeClient(new WebChromeClient());
After following Line of code:
webSettings.setJavaScriptEnabled(true);
Finally it Should look like:
webSettings.setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient());
Here is the answer from JavaScript alert not working in Android WebView Check this link , and last ment , You have to use WebChromeClient for your purpose.
http://code.google./p/android/issues/detail?id=752
This seems to be a bug introduced into build 40 of WebView. It is fixed in version 42 as per the issue I've logged.
https://code.google./p/chromium/issues/detail?id=478204
本文标签: androidWebview not showing JavaScript alertsStack Overflow
版权声明:本文标题:android - Webview not showing JavaScript alerts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745229108a2648744.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论