request.user_agent() returns a Storage object with lots of details about
the user agent. Try {{=BEAUTIFY(request.user_agent())}} in a view and visit
it from some Android devices. I think request.user_agent().dist.name ==
'Android' might work (not sure about all versions, though).
request.user_agent().os.name should be "Linux" in the case of Android.
Note, not all user agents have a "dist" attribute, so first check for the
attribute before checking for the name.
Anthony
On Thursday, August 30, 2012 2:36:09 PM UTC-4, Mark Li wrote:
>
> I would like to use request.user_agent to check if a device is an Android.
>
> I'm currently using is_mobile() to check and load the mobile view, but I
> would like to break it down one more step and add some code only for
> Android devices. Is there any way to go about this?
>
> And would this be more efficient than using Javascript device sniffer?
>
--