Tablet or Phone - Android

后端 未结 30 2146
难免孤独
难免孤独 2020-11-22 08:33

Is there a way to check if the user is using a tablet or a phone? I\'ve got problems with my tilt function and my new tablet (Transformer)

30条回答
  •  情歌与酒
    2020-11-22 09:10

    It is getting increasingly harder to draw the line between phone and tablet. For instance (as of Aug 2015) the Samsung Mega 6.3 device pulls resources from the sw600dp folders -- so as far as Android is concerned it is a tablet.

    The answer from @Vyshnavi works in all devices we have tested but not for Mega 6.3.

    @Helton Isac answer above returns the Mega 6.3 as a phone -- but since the device still grabs resources from sw600dp it can cause other issues - for instance if you use a viewpager for phones and not for tablets you'll wind up with NPE errors.

    In the end it just seems that there are too many conditions to check for and we may just have to accept that some phones are actually tablets :-P

提交回复
热议问题