x


How to get the Screen Size

Im developing a Android Game, and to adjust my camera, i need to check the size of the screen of my user, the actual inch of the display, and not the resolution. Because there are devices with the same display size and different resolutions.

In Android development this is fixed using the DP unit.

Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion.

more ▼

asked Jan 03 '11 at 12:52 AM

Potapczuk gravatar image

Potapczuk
145 7 7 15

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I asked this question a while back for iOS: http://answers.unity3d.com/questions/23490/is-there-a-way-to-detect-a-retina-display

Currently (as of Unity 3.1) there does not seem to be a way to do it- the iOS workaround is simply to enumerate known devices that have a retina display.

I do not have access to the Android version though, and given the proliferation of Android devices I would expect such a setting to be even more important So perhaps there's a solution for Android I don't know about.

more ▼

answered Jan 03 '11 at 02:18 AM

Bampf gravatar image

Bampf
5k 8 19 49

I found this: http://unity3d.com/support/documentation/ScriptReference/iPhoneSettings.html

Maybe it can help you, checking by the model of the device.

Jan 03 '11 at 03:16 AM Potapczuk

Yep, that's the answer I keep getting, but it potentially breaks when new models come out. So I'd prefer to know the actual DPI (which would also help you with your Android situation) or have a retina display indicator (iOS only.)

Jan 03 '11 at 08:41 PM Bampf
(comments are locked)
10|3000 characters needed characters left

I've ot the same trouble, i'll try to make a direct call to android api.

I'll post the solution here if i find it

more ▼

answered Sep 27 '11 at 03:28 PM

cfloutier gravatar image

cfloutier
67 2 2 7

Could you find a solution for that? I am currently having the same problem.

Jan 09 '12 at 12:00 PM taar1
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2482
x485

asked: Jan 03 '11 at 12:52 AM

Seen: 4709 times

Last Updated: Jan 09 '12 at 12:00 PM