Tuesday, August 11, 2015

Android: Detect 7" or 10" tablet programmatically (get smallest width dp)


Some other solutions out there are outdated.

This solution is when you are targeting API 13+. (You should now be targeting 14+ - written in 2015.08.11)

     int smallestDp = getResources().getConfiguration().smallestScreenWidthDp;  
     if(smallestDp >= 600 && smallestDp < 720) { // 7" ~ <10"  
     }  
     else if(smallestDp >= 720) { // 10"+  
     }