Thank you Lin, it worked. This is how I implemented it, in case someone is 
interested: http://stackoverflow.com/a/27533055/423171

 

I’ll switch to an official API as soon as it’s available. 

 

 

From: Huo, Halton [mailto:[email protected]] 
Sent: Thursday, December 18, 2014 6:44 AM
To: Sun, Lin; Cristian Perez
Cc: crosswalk-help
Subject: RE: [Crosswalk-help] How to change user agent in Crosswalk 9?

 

Should we add  this supporting? A new key  API in XWalkPreferences should be 
easy way.

 

Thanks,

Halton.

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of Sun, 
Lin
Sent: Thursday, December 18, 2014 1:32 PM
To: Cristian Perez
Cc: crosswalk-help
Subject: Re: [Crosswalk-help] How to change user agent in Crosswalk 9?

 

Hi Cristian,

 

Of course you can do anything via Java’s reflection feature, though not 
recommended.

 

Because there is already a reflection layer between org.xwalk.core and 
org.xwalk.core.internal, you must get the internal object via 
xwalkView.getBridge() firstly (This method is not public, but you have 
reflection). This is actually a XWalkViewInternal object so should be casted to 
its real type. Then get the XWalkSettings object from 
xwalkViewInternal.getSettings(), and set the user agent through XWalkSettings. 
Please note that this way is not supported officially and we would not ensure 
it works on all versions.

 

For details, please reference to the Crosswalk project on GitHub.

https://github.com/crosswalk-project/crosswalk/tree/master/runtime/android/core_internal/src/org/xwalk/core/internal

 

Thanks,

Lin

 

From: Cristian Perez [mailto:[email protected]] 
Sent: Thursday, December 18, 2014 01:35
To: Sun, Lin
Subject: Re: [Crosswalk-help] How to change user agent in Crosswalk 9?

 

We need to use at least Crosswalk-9 for compatibility reasons, but also need to 
change the user agent. Is there a way to modify the user agent string before 
Crosswalk-12 reaches the beta channel?

 

Is there a method I can call via reflection for example?

 

Thanks a lot,

Cristian

 

 

 

Sun, Lin Thu, 11 Dec 2014 18:40:54 -0800

 

In addition, the new API setting user agent will be like below:

 

xwalkView.setUserAgentString(newUserAgentString)

 

Thanks,

Lin

 

From: Crosswalk-help 

[mailto:[email protected]] On Behalf Of Sun, 

Lin

Sent: Thursday, December 11, 2014 15:49

To: George.Veivo; crosswalk-help

Subject: Re: [Crosswalk-help] How to change user agent in Crosswalk 9?

 

Hi George,

 

Actually, the API around XWalkView, what we call Embedding API,  some part of

them is not intended to be exposed to developers originally, but we had never 

forced

to forbidden the usage until Crosswalk-9.

 

Now we are drafting new Embedding API as developer’s need, also going to expose

some API we hided before what just includes the one you mentioned. It will be

introduced in Crosswalk-12, about the end of January next year.

 

Please feel free to contact us if you have any proposal around this.

 

Thanks,

Lin

 

From: Crosswalk-help 

[mailto:[email protected]] On Behalf Of 

George.Veivo

Sent: Tuesday, December 02, 2014 16:45

To: crosswalk-help

Subject: [Crosswalk-help] How to change user agent in Crosswalk 9?

 

Hi all,

 

We know we can change user agent in crosswalk 8 by 

webView.getSettings().setUserAgentString(newUserAgentString), however, this API 

is removed in crosswalk 9 and later versions. Anyone can tell me how to change 

user agent in crosswalk 9?

 

Thanks.

 

George‍

_______________________________________________

Crosswalk-help mailing list

[email protected] 
<mailto:[email protected]> 

https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Previous messageView by threadView by dateNext message

[Crosswalk-help] How to change user agent in crosswalk 9? George.Veivo

[Crosswalk-help] How to change user agent in Crosswalk 9... George.Veivo

Re: [Crosswalk-help] How to change user agent in Cro... Sun, Lin

Re: [Crosswalk-help] How to change user agent in... Sun, Lin

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

Reply via email to