Detecting mobile phones browser

1,039 views
Skip to first unread message

Ice13ill

unread,
Aug 14, 2010, 8:32:25 AM8/14/10
to Google Web Toolkit
I wont to know if by checking the "user.agent" property in the gwt.xml
file I can detect if the client is using a browser on a mobile phone
(like HTC wiht Android, or IPhone etc)

And also, are there "nasty" restrictions on the JS (thus GWT classes)
on those browsers ?(at least for those very widely used)

Shawn Brown

unread,
Aug 15, 2010, 3:02:41 AM8/15/10
to google-we...@googlegroups.com
> I wont to know if by checking the "user.agent" property in the gwt.xml

I don't know what that returns but have seen this in my servlets with
Android 2.1

"GET /myCache.manifest HTTP/1.1" 200 1120 - "Mozilla/5.0 (Linux; U;
Android 2.1-update1; en-us; HTC Magic Build/EPE54B) AppleWebKit/530.17
(KHTML, like Gecko) Version/4.0 Mobile Safari/530.17,gzip(gfe)"

...so if user.agent isn't telling you, I think you can figure it out
server side. User agent would return "safari" for this phone wouldn't
it?


> And also, are there "nasty" restrictions on the JS (thus GWT classes)
> on those browsers ?(at least for those very widely used)

I haven't seen any on the browser used for Android 2.1

Shawn

cokol

unread,
Aug 15, 2010, 4:23:28 AM8/15/10
to Google Web Toolkit
you can either use js browser detection script and work with it over
JSNI in GWT ( like http://javascript.about.com/library/blbrsdet.htm )
or a serverside solution ( like http://wurfl.sourceforge.net/ ) which
helps you to handle clients capabilities

gwt claims to work on every browser :) hence there is no explicit
support on mobile devices ( I suppose )

Andrei Cosmin Fifiiţă

unread,
Aug 15, 2010, 5:02:26 AM8/15/10
to google-we...@googlegroups.com
Thx for the answers but i found a way of defining my own property based on a javascript (in .gwt.xml file) which tests the complete user agent string for some keywords.
http://www.javaneverdie.com/gwt/want-to-show-mobile-or-phone-site-version-check-user-agent/

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Thomas Broyer

unread,
Aug 15, 2010, 10:36:18 AM8/15/10
to Google Web Toolkit
See http://code.google.com/p/gwt-mobile-webkit/ (and there are
probably other projects out there)

If you can, you should use deferred binding (with a property-provider)
instead of checking Window.Navigator in your code (this would mean you
download both the mobile and "desktop" versions, but just don't run
the "desktop" parts)

Thomas Broyer

unread,
Aug 15, 2010, 10:51:06 AM8/15/10
to Google Web Toolkit


On 15 août, 16:36, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 14 août, 14:32, Ice13ill <andrei.fifi...@gmail.com> wrote:
>
> > I wont to know if by checking the "user.agent" property in the gwt.xml
> > file I can detect if the client is using a browser on a mobile phone
> > (like HTC wiht Android, or IPhone etc)
>
> > And also, are there "nasty" restrictions on the JS (thus GWT classes)
> > on those browsers ?(at least for those very widely used)
>
> Seehttp://code.google.com/p/gwt-mobile-webkit/(and there are
> probably other projects out there)

See also this example:
http://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties#Example_2:_Avoiding_permutation_explosion

Andrei Cosmin Fifiiţă

unread,
Aug 15, 2010, 12:39:09 PM8/15/10
to google-we...@googlegroups.com
Yep, that is exactly what i did :) (property-provider and replace-with tags)

Reply all
Reply to author
Forward
0 new messages