D
Deleted member 103
Guest
Hi,
I have 2 smartphone with 5 inch display, a samsung-s4 and a HTC-one-a9.
The ApproximateScreenSize and ExactSize functions show two different results.
Where can I get the info that the 2 devices have a 5 inch display?
I have 2 smartphone with 5 inch display, a samsung-s4 and a HTC-one-a9.
The ApproximateScreenSize and ExactSize functions show two different results.
Where can I get the info that the 2 devices have a 5 inch display?
Samsung-S4:
ApproximateScreenSize=4.589389937671455
ExactSize=4.675465685446727
HTC-one-A9:
ApproximateScreenSize=4.330415684434925
ExactSize=4.371859576504938
B4X:
Sub getDeviceSize As Double
Dim lv As LayoutValues
lv = GetDeviceLayoutValues
Log("ApproximateScreenSize=" & lv.ApproximateScreenSize)
Log("ExactSize=" & ExactSize)
Return lv.ApproximateScreenSize
End Sub
Sub ExactSize As Double
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
r.Target = r.RunMethod("getDisplayMetrics")
Dim xdpi As Double = r.GetField("xdpi")
Dim ydpi As Double = r.GetField("ydpi")
Return Sqrt(Power(100%x / xdpi, 2) + Power(100%y / ydpi, 2))
End Sub