的WebView不能在Android的L器件加载JavaScript的警示 [英] Webview can not load JavaScript Alert in android L devices
问题描述
,在iFrame中有使用JavaScript警告的。
JavaScript警告是工作的罚款中的所有设备属于API< 20但在20 API,警报不工作。
像这是给我的logcat消息
(不能创建一个对话框,web视图上下文不是一个Activity)
块引用>我曾尝试以下code此:
webview.getSettings()setLoadWithOverviewMode(真)。
webview.getSettings()setDomStorageEnabled(真)。
webview.getSettings()setJavaScriptEnabled(真)。
。webview.getSettings()setPluginState(PluginState.ON);
。webview.getSettings()setAllowFileAccess(真);
webview.setClickable(真);
webview.setFocusableInTouchMode(真); WebClientClass webViewClient =新WebClientClass();
webview.setWebViewClient(webViewClient);
WebChromeClient webChromeClient =新WebChromeClient(){
@覆盖
公共布尔onJsPrompt(的WebView视图,URL字符串,字符串消息,
串设置defaultValue,JsPromptResult结果){
Log.d(jsPrompt:,OK+网址);
返回super.onJsPrompt(查看,网址,邮件,设置defaultValue,
结果);
} @覆盖
公共布尔onJsAlert(的WebView视图,URL字符串,字符串消息,
JsResult结果){
Log.d(jsAlert:,OK+网址);
// TODO自动生成方法存根
返回super.onJsAlert(查看,网址,邮件,结果);
}
};
wvTourDetails.setWebChromeClient(webChromeClient); 如果(网址!= NULL){
webview.loadUrl(URL);
}是否有任何人,谁可以帮助我在android的L器件使用警报。
感谢
解决方案我得到这个问题的解决方案。
谷歌已经在2015年4月24日,更新的Android系统WebView到42版。
更新Android系统WebView在Android L移动设备用JavaScript来的工作。
I am using iFrame to load data to my application, In iFrame there is use of javascript alert.
javascript alert is working fine in all devices belongs to api < 20 but in api 20, alert is not working.
It is giving me logcat message like
(Cannot create a dialog, the WebView context is not an Activity )
I have tried following code for this:
webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setDomStorageEnabled(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setPluginState(PluginState.ON); webview.getSettings().setAllowFileAccess(true); webview.setClickable(true); webview.setFocusableInTouchMode(true); WebClientClass webViewClient = new WebClientClass(); webview.setWebViewClient(webViewClient); WebChromeClient webChromeClient = new WebChromeClient() { @Override public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { Log.d("jsPrompt:", "OK:" + url); return super.onJsPrompt(view, url, message, defaultValue, result); } @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { Log.d("jsAlert:", "OK:" + url); // TODO Auto-generated method stub return super.onJsAlert(view, url, message, result); } }; wvTourDetails.setWebChromeClient(webChromeClient); if (url != null) { webview.loadUrl(url); }
Is there anyone, who can help me to use alert in android L Devices..
Thanks
解决方案I got solution for this problem.
Google has updated Android System WebView to version 42 on 24th April,2015.
Update your Android System WebView to work with javascript in Android L device
这篇关于的WebView不能在Android的L器件加载JavaScript的警示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!