Reputation: 2905
I have two devices, Samsung Tab 4 and Samsung J Max. Screen size and resolutions are same (Screen Size : 7" Resolution : 800x1280) but when i run following code its returning different values.
Configuration configuration = this.getResources().getConfiguration();
int screenWidthDp = configuration.screenWidthDp;
int densityDPI = configuration.densityDpi;
Samsung Tab 4 screenWidthDp = 600 densityDPI = 213
Samsung J Max screenWidthDp = 533 densityDPI = 240
Does anybody know the reason?
Upvotes: 0
Views: 995
Reputation: 12929
The manufacturer decides the density setting of the screen of the devices. Usually it tries to align that setting to predefined density buckets (hdpi or tvdpi for example).
The major difference here is that the J Max is sold as a large phone while the Tab 4 is a tablet. In the Android developers documentation there is some consensus that the definition of a tablet is a device with a screen whose smallest width is at least 600dp (think of layout-sw600dp
resources folder).
So for the Tab 4 Samsung chose to use the tvdpi density bucket, in order for the screen space to reach a smallest width of 600dp, thus apps will work in tablet mode when available. For the large phone they chose a density bucket of hdpi so the smallest width of the screen is right below 600dp at 533dp so apps will still display in phone mode.
Upvotes: 2