Detecting screen resolution

rfresh

Well-Known Member
Licensed User
Longtime User
I got this code to detect screen resolution below. However, my Iconia A500 is spec'd to have a screen resolution of 1280x800 but the code 'detects' it at 1280x752 at 160dpi.

Can anyone see what might be causing the 752 finding when it's an 800 screen? Also, the dpi isn't 160, it's 149 (although 160 is close enough but I'm just wondering why it doesn't get that number).


Code:
Sub Get_Screen_Resolution
   pScreenWidth=GetDeviceLayoutValues.Width
   pScreenHeight=GetDeviceLayoutValues.Height
   pScale=GetDeviceLayoutValues.Scale
   If pScale= 0.75 Then
   pDPI="120"
   End If
   If pScale= 1 Then
   pDPI="160"
   End If
   If pScale= 1.5 Then
   pDPI="240"
   End If
   If pScale=2 Then
   pDPI="320"
   End If
End Sub
 
Yes...so that means it is returning 752 because that's what is usable?

Hmmm...for other devices that I don't have to test on, I don't know if they have soft keys or not. I was hoping to detect the full screen resolution because I can find thos published specs for any device (especially when I don't have one to test with).

Is there a way to grab the full screen size?
 
Last edited:
Upvote 0
You will have to setup your app to FULL SCREEN, you can do that using the designer Project -> Activity Properties and check Full screen and uncheck Include title.

However, systems with permanent on-screen-softkeys might still use part of the screen and you will not get an actual resolution.
 
Upvote 0
I personally prefer using percentages for layouts (i.e. 90%x, 66%y). Of course it depends on the type of app you are making and if it would work for your layouts.
 
Upvote 0
I am using % for the laying out of my UI components but I'm detecting what device is being used by it's published screen specs.
 
Upvote 0
You will have to setup your app to FULL SCREEN, you can do that using the designer Project -> Activity Properties and check Full screen and uncheck Include title.

However, systems with permanent on-screen-softkeys might still use part of the screen and you will not get an actual resolution.

Ahhhh so maybe that will let my Iconia 10 incher report 1280x800 vs 1280x752. I'll try it this evening. Thanks.
 
Upvote 0
You will have to setup your app to FULL SCREEN, you can do that using the designer Project -> Activity Properties and check Full screen and uncheck Include title.

However, systems with permanent on-screen-softkeys might still use part of the screen and you will not get an actual resolution.

Yeah, my Acer Iconia A500 is still showing 1200x752 vs 1200x800 even with FULL SCREEN enabled.

So now I guess my question is: what is the best way to identify what Android device my app is running on?
 
Upvote 0
Hmmm...I guess I'll have to have a setup screen where the user selects the closest screen resolution to their device. I'm positioning my UI components by % of the screen resolution so I think if they select a close screen size the components should position close enough.

I'm not sure how else to do this.
 
Upvote 0
I got this code to detect screen resolution below. However, my Iconia A500 is spec'd to have a screen resolution of 1280x800 but the code 'detects' it at 1280x752 at 160dpi.

Can anyone see what might be causing the 752 finding when it's an 800 screen? Also, the dpi isn't 160, it's 149 (although 160 is close enough but I'm just wondering why it doesn't get that number).

See Designer - Basic4android Wiki. The scales are not a specific resolution, such as 160. They are a range of resolutions and the ranges actually overlap a little. This is described at the link just given.
 
Upvote 0
This is very common on Android 3.2 and 4.0 devices, they reserve the bottom 48 pixels for the taskbar.
 
Upvote 0
Back
Top