1
votes

Can someone provide an example of how I could change the user agent in a cordova android application, using Crosswalk 14.43.343.23 and the cordova plugin crosswalk webview?

I have no idea how to get the settings in MainActivity and change the user agent. I know there is a setUserAgentString for the XWalkView , but how do I access the view?

Edit: I tried using setUserAgentString but I got java.lang.UnsupportedOperationException: setUserAgentString

1
I got the same error in crosswalk 15.44.384.13.android_su

1 Answers

0
votes

Something like this:

XWalkView xwalkView = (XWalkView) this.appView.getEngine().getView();
        try {
            Method ___getBridge = XWalkView.class.getDeclaredMethod("getBridge");
            ___getBridge.setAccessible(true);
            XWalkViewBridge xWalkViewBridge;
            xWalkViewBridge = (XWalkViewBridge) ___getBridge.invoke(xwalkView);
            XWalkSettings xWalkSettings = xWalkViewBridge.getSettings();
            xWalkSettings.setUserAgentString("");
        } catch (Exception ex) {}