gpt4 book ai didi

Android facebook 喜欢使用 webview

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:39:42 25 4
gpt4 key购买 nike

我使用以下代码在 web View 中加载类似 facebook 的按钮。

            likeWebView = (WebView)findViewById(R.id.webview);
likeWebView.getSettings().setJavaScriptEnabled(true);

url ="http://www.facebook.com/plugins/like.php?" +
"href=" + URLEncoder.encode( "http://developers.facebook.com/docs/opengraph/" )
+ "&" +
"layout=button_count&" +
"show_faces=0&" +
"width=90&" +
"height=24&" +
"locale=en_IN" +
"colorscheme=light" ;

likeWebView.loadUrl( url );

问题是当用户在登录过程中将他重定向到一个空白页面,我如何拦截此 webview 请求并取消此操作/关闭 webview?

最佳答案

public class WebViewPreLoad extends WebView{
public WebViewPreLoad(Context context) {
super(context);
}
public void loadUrl(String str){
if(str.contains("something"))
super.loadUrl(str);
else
hide this
}
}

当然,你必须为你的情况找到正确的“如果”

同样,用

做同样的事情
 public void loadUrl(String url, Map<String,String> extraHeaders)

将 super 语句更改为:

super.loadUrl(url, extraHeaders);

关于Android facebook 喜欢使用 webview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6646914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com