Android Question Problem with reflection "GetField("xdpi")" with various resolutions

welu1805

Active Member
Licensed User
Longtime User
Hi all,

I want to calculate the physical width of my tablets in centimeters.

Dim r As Reflector
Dim x As Float

r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
r.Target = r.RunMethod("getDisplayMetrics")

x = r.GetField("xdpi")

Log(x & " " & 100%x & " " & (100%x / x * 2.54))

I have two 9,7" tablets. One with 1024 x 768 (a) the other with 2048 x 1536 (b)

The physical width in centimeters is 100%x / x * 2.54.

The tablet (a) shows 132.70204162597656 768 14.699999910311437
The tablet (b) shows 288.99554443359375 1536 13.500000519546019

The physical width of both tablets is 14.7 cm!

The calculated width of tablet (b) is wrong.

Does anyone know what is the problem?

Lutz
 
Top