Hi Décio,

Thank you for the reporting! Currently the setUserAgentString() API can only 
effect xwalk loading, the downloading will keep using default system user 
agent, the new bug XWALK-4625 has been reported, please track it.

https://crosswalk-project.org/jira/browse/XWALK-4625  Embedding API 
setUserAgentString can't affect xwalk downloading



If you need a  temporary workaround,  please try to add 
request.addRequestHeader("User-Agent", yourCustomUserAgent)  as follows:



         xwalkview.setDownloadListener(new 
XWalkDownloadListener(getApplicationContext()) {

                   @Override

                   public void onDownloadStart(String url, String userAgent,

                                            String contentDisposition, String 
mimetype, long contentLength) {

                            Uri src = Uri.parse(url);

                            if (src.getScheme().equals("http") || 
src.getScheme().equals("https")) {

                                     Request request = new Request(src);

                                     request.addRequestHeader("User-Agent", 
yourCustomUserAgent);

                                     
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, 
fileName);

                                     DownloadManager downloadManager =

                                                                 
(DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);

                                     downloadManager.enqueue(request);

                            }

                   }

         })

BR
Belem

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of Décio 
Macedo
Sent: Thursday, July 16, 2015 3:12 AM
To: [email protected]
Subject: [Crosswalk-help] Custom User Agent problem

Hi,

I've been using Crosswalk Webview with a custom user agent, it works fine most 
of the time except when it downloads the cache.manifest file.
When I call loadurl(), Crosswalk will use the custom user agent to get the 
index.html but when it downloads the cache.manifest it will use the default 
user agent. For everything else after this it will use the custom user agent 
again.
I need to use the custom user agent to download the cache.manifest because this 
file is being generated according to the user agent.

Is there any other way to force it to use the custom user agent all the time?

Best regards,
Décio Macedo
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to