我正在使用XWalkView加载一个页面。
我想知道是否有可能拦截页面中链接的加载请求,并将其加载到一个新的意图弹出或停止加载链接。
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view,
String url) {
Log.d("shouldInterceptLoadRequ","shouldInterceptLoadRequest " + url);
return super.shouldInterceptLoadRequest(view, url);
}当页面有链接时,不会调用这一点。当页面有链接时,我会看到一个android默认弹出,请求浏览器打开链接。
我需要的是打开谷歌地图应用程序,如果网址是谷歌地图的位置。
我确实尝试过使用默认的android WebView,但是html5支持太弱了。
编辑的
我应该用
public boolean shouldOverrideUrlLoading(XWalkView view, String url)但是看起来它有一个带有外部链接的bug:
https://crosswalk-project.org/jira/browse/XWALK-3606
编辑2
当链接有target="_blank“时,问题就会发生。
发布于 2015-05-15 12:36:53
public class MyActivity extends Activity {
private XWalkView xWalkWebView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity_xml);
xWalkWebView = (XWalkView)findViewById(R.id.xwalkView);
xWalkWebView.addJavascriptInterface(new WebAppInterface(), "Android");
xWalkWebView.load(url_your_want_to_load,null);
}
public class WebAppInterface {
@org.xwalk.core.JavascriptInterface
public void callFunction(){
// Do your Android Stuff here
}
}现在调用页面中的函数为:- Android.callFunction();
发布于 2015-05-15 13:46:29
它固定在测试版:14.43.343.1
shouldOverrideUrlLoading和shouldInterceptLoadRequest现在都在工作。
https://stackoverflow.com/questions/29681825
复制相似问题