i was wondering if GWT can detect if browser (mobile/desktop) can open pdf files?
in my application, clicking a gwt-Button (named PDF) will generate a pdf report. the pdf creation happens on the server-side (php), and all i have to do is to call a specific action. The server includes application/pdf as its Content-type.
now, testing my PDF button in iPad/iPhone(simulator) opens a new tab which displays the PDF report generated while on an Android emulator (an Android SDK for Mac run on eclipse), it downloads the .php that process the pdf report not the pdf file generated. so i decided to view my PDF button only to those browser that can open PDF file. how to do this?
upon checking the user-agent:
iPad simulator = Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F192 Safari/6533.18.5
for my Android emulator =Mozilla/5.0 (Linux; U; Android 4.1; en-us; sdk Build/JRN83C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 Safari/6533.18.5
You probably have some error in your code, because a .php should never be downloadable!
For your pdf-detection problem check this jquery-plugin:
http://plugins.jquery.com/browser/
You can insert it in your html and get its result via a native method in GWT. Not the cleanest solution, but it should work as you need it.
Related
I want to use WhatsAppWeb (web.whatsapp.com) in an Android app. I've tried using a WebView and load the URL but I'm redirected to the regular WhatsApp page (www.whatsapp.com). I tried changing the User Agent
mWebView.getSettings().SetUserAgentString("Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 78.0.3945.79 Safari / 537.36");
but this only works if the app is started the first time. Each further start it redirects. Deleting Cache works (no redirect) but then I have to "authenticate" the device again.
Any ideas?
Did you try using custom webview client? Please check this http://www.technotalkative.com/android-webviewclient-example/
I am trying to download an image from Java code. My code is already working fine for tons of other images, but this one refuses to download.
I'm sure the image exists and I am able to view it inside the browser: http://lemonde-emploi.blog.lemonde.fr/files/2017/02/La-Ru%C3%A9e-des-licornes-Hazard.jpg
I'm using Play framework WS Scala client to download the image. It's just a wrapper around Java famous AsyncHttpClient with a Netty implementation.
I'm running the following code, which work fine for many other images, but fails just for this one:
WS
.url(url)
.withQueryString(queryString: _*)
.withHeaders("User-Agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.get
I've set exactly the same User-Agent as my local browser which succeed to access the image.
Here's the server response in debug: it returns a 400 status code.
Any idea why it happens?
The legacy "com.ning" package in your image shows that you're still running AHC1, that has reached end-of-life and I no longer maintain.
You're most likely hitting an old AHC bug related to URL encoding that's been long fixed (I checked that modern releases of AHC2 work fine with your URL).
Basically, it's time to consider upgrading Play/AHC versions.
`Hi,
I am trying to get the user's browser information in my servlet filter. I used a simple code, see below.
String userAgent = request.getHeader("User-Agent");
User was using Google chrome, and what the above code printed is below.
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
It printed the names of all the major browsers instead of getting the once the app is running. what is wrong here?
Nothing is wrong here.
For example let us consider the returned string is
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
Then the explanation is
ChromeChrome 41.0.2228.0
Mozilla ==>
MozillaProductSlice. Claims to be a Mozilla based user agent, which is only true for Gecko browsers like Firefox and Netscape. For all other user agents it means 'Mozilla-compatible'. In modern browsers, this is only used for historical reasons. It has no real meaning anymore
5.0 ==> Mozilla version
Windows NT 6.1 ==> Operating System Windows 7
AppleWebKit ==> The Web Kit provides a set of core classes to display web content in windows
537.36 ==> Web Kit build
KHTML ==> Open Source HTML layout engine developed by the KDE project
like Gecko ==> like Gecko...
Chrome Name ==> Chrome
41.0.2228.0 ==> Chrome version
Safari ==> Based on Safari
537.36 ==> Safari build
Description: Free open-source web browser developed by Google.
Chromium is the name of the open source project behind Google Chrome, released under the BSD license.
You can find more information in below link
http://www.useragentstring.com/pages/Chrome/
click on each link on the page to get more info
I'm currently working on an app for a website/class. Currently, it pulls the RSS feed of the site, parses it appropriately, and when an item is clicked, it launches a new Activity with a WebView to display the page.
My current problem is that on smaller devices, such as the HTC One or Samsung Stratosphere, it defaults to showing the mobile version of the site. This is precisely what I want to happen across all devices, but on my Samsung Galaxy Note 8, it defaults to loading the desktop version of the page.
Is anyone familiar with WordPress and Android and can help me force the WebView on the Galaxy (and, therefore, other devices) to load the mobile page by default?
Thank you!
Use WebSettings object obtained by the WebView's getSettings() Method and change the UserAgent string.
WebSetting settings = webView.getSettings();
settings.setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0");
For current Firefox 26.0 or browser of your choice. This should force the Website to display in Desktop mode, since this is what the Websites do to determine if they serve a mobile or desktop version.
Update:
You an also force it mobile by using mobile UserAgent. For more information check out this website with example UserAgents.
Some examples for historical references if the link becomes invalid:
Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Mozilla/5.0 (Linux; U; Android 4.0.3; de-ch; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
http://www.useragentstring.com/pages/useragentstring.php
WebSettings
I am setting user-agent to test a iOS app from my Java client this way -
urlc.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0");
However, in the JSON response I am getting an error that this app can only be tested on an iOS device (which is a custom response I have when the app is tested from a non-IOS device. So what is the correct way to set user-agent in Java?
A browser sends a special string, called a user agent, to websites to identify itself. The web server, or JavaScript in the downloaded webpage, detects the client’s identity and can modify its behavior accordingly. In the simplest case, the user agent string includes an application name—for example, Navigator as the application name and 6.0 as the version. Safari on the desktop and Safari on iOS have their own user agent strings, too.
https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html
UserAgent complete set
UserAgent complete set ssfari