Reputation: 167
I am currently building an Android application (a game). I have created ldpi, mdpi and hdpi of all of the images (the dimensions of all of these images have been appropriately calculated).
When I test the game on my Samsung S3, the value of the below code is 2.0.
getResources().getDisplayMetrics().density;
This is correct, and all images used in the application are automatically selected from the drawable-hdpi folder.
However, when I test the application on my Google Nexus One, the above code evaluates to 1.5 (correctly), and yet images from the drawable-hdpi folder are still automatically selected.
For reference, I am loading the bitmaps in this manner:
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inScaled = false;
Bitmap exampleBitmap = BitmapFactory.decodeResource(gamePanel.getResources(), R.drawable.example, bmpFactoryOptions);
EDIT: Removing the second line still does not fix the issue.
Am I doing something wrong? If so, what? Alternatively, is there a workaround?
Many thanks in advance.
Upvotes: 0
Views: 1377
Reputation: 76466
The Samsung Galaxy SIII is an XHDPI device.
The Nexus One is a HDPI device.
Reference:
http://blog.blundellapps.com/list-of-android-devices-with-pixel-density-buckets/
Therefore, because you don't have XHDPI resources, it uses the next closest for the SIII (hdpi).
Upvotes: 4
Reputation: 134664
I'm fairly certain that the S3 (2.0 density) is xhdpi, whereas the Nexus One (1.5 density) is hdpi. 1.0 is the reference density (mdpi). What's most likely happening is that the S3 is falling back to the hdpi folder since you've not provided xhdpi resources, and the Nexus One is correctly pulling from the hdpi folder.
Upvotes: 1