Hi Zhang,

Thanks you for your support. The code you've provided was not directly working 
because it opens a new browser instead of working in the webview. But using 
your idea this code is working :

@Override
public boolean shouldOverrideUrlLoading(XWalkView xWalkView, String url) {

if (mOverride && !url.contains("numMag")) {
Uri.Builder builder = Uri.parse(url).buildUpon();
builder.appendQueryParameter("numMag", mNumSite);
String newUrl = builder.build().toString();
Log.d(MyNewWebView.TAG, newUrl);
xWalkView.load(newUrl,null);
return true;

}
else
return false;

}



Regards

Vincent.

________________________________
De : Zhang, Xiaofeng <[email protected]>
Envoyé : jeudi 5 mai 2016 11:10:18
À : Zhang, Xiaofeng; Vincent AROD; [email protected]
Objet : RE: [Crosswalk-help] Android - override url in order to add parameters


Hi,

Thanks using Crosswalk.
I have tested on Android WebView, it has the same result with xwalk.
I think you can't use this API like that, because "return 
super.shouldOverrideUrlLoading(xWalkView,newUrl);" will actually call below:

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return false;
}

So the newUrl is invalid.

If you use it like below, it works well:

            @Override
            public boolean shouldOverrideUrlLoading(XWalkView view, String url) 
{
                Log.i(LOGTAG, "shouldOverrideUrlLoading  ");
                    startActivity(new Intent(Intent.ACTION_VIEW, 
Uri.parse(injectIsParams(url))));
                    return true;
            }
        });

Best Regards :)
Xiaofeng Zhang

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of 
Vincent AROD
Sent: Wednesday, May 04, 2016 8:49 PM
To: 
[email protected]<mailto:[email protected]>
Subject: Re: [Crosswalk-help] Android - override url in order to add parameters


Hi again,



I've also tested in the latest release version v18 and I got the same result.



If you have any idea :)



Vincent.

________________________________
De : Vincent AROD
Envoyé : mercredi 4 mai 2016 11:23:54
À : 
[email protected]<mailto:[email protected]>
Objet : Android - override url in order to add parameters


Hello all,


we are using xwalk core apis in our project in order to get a better android 
webview than os native version. Thanks you for this great project.

I would like to add parameters in url to setup the site ?numMag=XXX
on standard android webview we are using shouldOverrideUrlLoading to change url 
and return the parent method
We try do the same in xwalk with shouldOverrideUrlLoading and 
shouldInterceptLoadRequest in XWalkResourceClient but it doesn't override url.

Here is the piece of code :

if (mOverride) {
    Uri.Builder builder = Uri.parse(url).buildUpon();
    builder.appendQueryParameter("numMag", mNumSite);
    String newUrl = builder.build().toString();
    Log.d("Override", newUrl);
}

return super.shouldOverrideUrlLoading(xWalkView,newUrl);
what is expected is that the webview loads url + "?numMag=XXX" but it loads 
only original url.

do you have any idea ?

we are working with v16 (yeap an old one)



Thanks you.

Vincent.

_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to