adrnsoh / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

getDeviceDensity() return wrong result #51

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Motorola Milestone
2. Display.getInstance().getDeviceDensity()
3. returns 30

What is the expected output? What do you see instead? 40

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by hamed.za...@gmail.com on 24 Feb 2012 at 4:59

GoogleCodeExporter commented 9 years ago

Original comment by shai.almog on 24 Feb 2012 at 6:36

GoogleCodeExporter commented 9 years ago

Original comment by shai.almog on 29 Feb 2012 at 3:43

GoogleCodeExporter commented 9 years ago
that's strange can you please check on the device what's the output of:

DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
System.out.println(metrics.densityDpi);

Original comment by cf27...@gmail.com on 29 Feb 2012 at 3:55

GoogleCodeExporter commented 9 years ago
Yeah that's strange
Output is 240

Original comment by hamed.za...@gmail.com on 29 Feb 2012 at 4:21

GoogleCodeExporter commented 9 years ago
Thanks,
Can you also run this and let me know the result:

            DisplayMetrics dm = activity.getResources().getDisplayMetrics();
            float screenWidth = dm.widthPixels / dm.xdpi;
            float screenHeight = dm.heightPixels / dm.ydpi;
            double size = Math.sqrt(Math.pow(screenWidth, 2)
                    + Math.pow(screenHeight, 2));

what's the value of size

Original comment by cf27...@gmail.com on 1 Mar 2012 at 10:31

GoogleCodeExporter commented 9 years ago
Of course
returns: 10.20469720465169

Original comment by hamed.za...@gmail.com on 1 Mar 2012 at 11:22

GoogleCodeExporter commented 9 years ago
Thanks, according to this we assume your device is a tablet 10 inch, therefore 
we return medium density.

is it a tablet 10inch? 

Original comment by cf27...@gmail.com on 1 Mar 2012 at 11:50

GoogleCodeExporter commented 9 years ago
No!
My device is a Motorola Droid (Milestone) A853

Original comment by hamed.za...@gmail.com on 1 Mar 2012 at 11:55

GoogleCodeExporter commented 9 years ago
Ok, so there is a bug in our calculation or the device returns wrong values.
Can you please give the output of the above:

float screenWidth = dm.widthPixels / dm.xdpi;
float screenHeight = dm.heightPixels / dm.ydpi;

What are the values of: dm.widthPixels, dm.xdpi, dm.heightPixels, dm.ydpi, 
screenWidth, screenHeight

Thanks

Original comment by cf27...@gmail.com on 1 Mar 2012 at 12:07

GoogleCodeExporter commented 9 years ago

The Log file of values as ordered by you are:
dm.widthPixels, dm.xdpi, dm.heightPixels, dm.ydpi, screenWidth, screenHeight
03-01 15:46:13.952: I/Display Info(4666): 480 96.0 854 96.0 5.0 8.895833

but i should say the lwuit version and thorsten`s port works fine

Original comment by hamed.za...@gmail.com on 1 Mar 2012 at 12:19

GoogleCodeExporter commented 9 years ago
Thanks, seems like it's a motorola device bug:
http://comments.gmane.org/gmane.comp.handhelds.android.devel/110221

The xdpi should be reported 264 and not 96.
I am leaving this bug open, we will need to think of a way to workaround this 
device bug.
Thanks for all the help on this issue.

Original comment by cf27...@gmail.com on 1 Mar 2012 at 12:38

GoogleCodeExporter commented 9 years ago
your welcome
i am at your service ;)

Original comment by hamed.za...@gmail.com on 1 Mar 2012 at 12:43