Figure 1: M-Mathurat on tablet (left) and on phone (right).
Preliminary designed for small screen Android smartphone, we decided to support bigger screen in Android tablet (Samsung Galaxy Note and above). The main reason is, more than 20% of the device installing m-Mathurat are big screen devices (Figure 2), and 10% are using Android Honeycomb (Figure 3).
Figure 2: M-Mathurat active device installs (device type) statistic.
Figure 3: M-Mathurat active device installs (Android versions) statistic.
The Android management team (especially Andy Rubin) believe that there suppose only one version of app for all devices. Meaning that there is only one release of app that could cater smaller screen smartphone and also tablet. Yeah… Heck of terrible days for developer, definitely. Anyway, we managed to get through.
What we did was, checking the screen size during the application start. Referring to the official reference of Android (http://developer.android.com/guide/practices/screens_support.html), xlarge screens are normally more than 960dpi width.
The code to determine the screen width in dpi is;
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated
if (height>width){
width=height;
}
//normal smartphone screen
if(width<960){
//set orientation to portrait
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
//big screen tablet
else {
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
Comments
Post a Comment