无法在 android webview 中打开 twitter url
我的 ANDROID 应用程序出现问题。
我想在我的网络视图中显示 Twitter 页面,但 URL 无法打开。
它不断加载。
我使用的是sdk 1.6。
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.setBackgroundColor(0x00000000);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
final Activity activity = this;
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 100);
Log.e("progress",progress+" "+((progress * 100)));
if(progress==100)
{
//getWindow().setFeatureInt(Window.FEATURE_PROGRESS,Window.PROGRESS_VISIBILITY_OFF);
indicator.setVisibility(View.GONE);
}
else
{
indicator.setVisibility(View.VISIBLE);
}
}
});
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new ApplicationWebViewClient());
}
private class ApplicationWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
I have a problem in my ANDROID application.
I would like to display a twitter page in my webview but the URL won't open.
It keeps loading infinitely.
I am using sdk 1.6.
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.setBackgroundColor(0x00000000);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
final Activity activity = this;
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 100);
Log.e("progress",progress+" "+((progress * 100)));
if(progress==100)
{
//getWindow().setFeatureInt(Window.FEATURE_PROGRESS,Window.PROGRESS_VISIBILITY_OFF);
indicator.setVisibility(View.GONE);
}
else
{
indicator.setVisibility(View.VISIBLE);
}
}
});
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new ApplicationWebViewClient());
}
private class ApplicationWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这对我有用!
This worked for me!
我必须在网络视图上设置用户代理字符串才能使其正常工作。
wv.getSettings().setUserAgentString("silly_that_i_have_to_do_this");
这对我有用。
希望它对其他人有帮助!
I had to set the User Agent String on the webview to get it to work.
wv.getSettings().setUserAgentString("silly_that_i_have_to_do_this");
and that worked for me.
Hope it helps someone else!
您的问题是您的
shouldOverrideUrlLoading
需要返回 true 以指示主机应用程序正在管理负载:Your problem is that your
shouldOverrideUrlLoading
needs to return true to indicate that the host application is managing the load: