Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distinguishing between phone and tablet browsers

I know this question as been beaten to death, but I don't want anything super complicated here.

We have a companion app with our site that is only compatible with 7 and 10-inch tablets. We need to only alert users on those devices about our app. Problem is, I can't go by resolution. My Galaxy S3 has a 1280 x 720 screen, but is obviously not a tablet. I also can't for the life of me find out a way to get the physical size of the screen. The only solution I have come up with is detecting whether the device can make calls with MobileCapabilities.CanInitiateVoiceCall. Unfortuantely, by boss isn't happy with that solution.

So... How can I distinguish between a phone and a tablet in my web app (Server or client side)?

UPDATE: So far it seems that the best approach for Android is something from a blog post by the Android team: All Android phones use "Mobile" in the UserAgent string, so checking for "Mobile" *and "Android" will tell you if it's a phone, while just "Android" should be a tablet. iOS devices should be just as simple--checking for "iPhone" vs "iPad" seems to have worked so far.

like image 332
Stephen Collins Avatar asked Feb 18 '13 20:02

Stephen Collins


People also ask

What is the difference between a tab and a phone?

What is the difference between tablets and smartphones? The main difference is the size of the screen. Smartphones usually have screen sizes between 4″/10cm and 7″/17cm, a tablet is anything over this. When it comes to processing power and available apps—they usually share the same capabilities.

Can I use my Android tablet as a phone?

With the Call & text on other devices feature, you can make and receive calls on your tablet as long as it's signed into the same Samsung account as your phone. You can also send messages. However, the connected phone will need to have active service.

What makes a great Android tablet browser?

A great Android tablet browser is designed for large screens. The user experience on tablets and phones is different. A tablet-optimized browser will take advantage of the larger screen size. A larger screen size opens up a lot of possibilities for how the app’s user interface (UI) is presented.

What is the difference between mobile and tablet?

Difference Between Mobile and Tablet 1 • Tablets are miniature laptops with a major difference that they are like a slate while laptops have a briefcase design. 2 • When we try to contrast tablets with mobiles, we find that barring the ability to make and receive voice calls there... More ...

Can Android apps run on a tablet?

Although Android tablets can run all Android apps, Android apps with a well-designed tablet interface are few and far between. Many browsers are optimized for smartphones but not for tablets. An interface that is stretched-out (like it would be on a 6-inch screen) is not why you got a tablet. What makes a great Android tablet browser?

Do we use tablets more often than smartphones?

Copyright terms and licence: CC BY-SA 3.0 In general smartphones and tablets get about equal use across the course of the day but in the evenings, again according to Flurry, there is a distinct peak of tablet use over smartphone use.


1 Answers

I know this is a little late, but I was looking for the same thing.

Wurfl has wat you want. You can implement it easily and and even have an api you can query.

For ASP.NET application first you must place the one-off initialization.

public class Global : HttpApplication
{
   public const String WurflDataFilePath = "~/App_Data/wurfl.zip";
   private void Application_Start(Object sender, EventArgs e)
   {
       var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath);
       var configurer = new InMemoryConfigurer().MainFile(wurflDataFile);
       var manager = WURFLManagerBuilder.Build(configurer);
       HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
   }
}  

And then use it like this.

var device = WURFLManagerBuilder.Instance.GetDeviceForRequest(userAgent);
var isTablet = device.GetCapability("is_tablet");
var isSmartphone = device.GetCapability("is_smartphone");

For more info check ASP.NET implementation

Hope this helps anyone else looking for this.

like image 196
arpad Avatar answered Sep 23 '22 11:09

arpad