On Fri, Dec 17, 2010 at 7:38 AM, Neilz <[email protected]> wrote:
> Thanks Mark... I've had a quick stab but I'm missing something...
>
> Class clazz=Class.forName("android.util.DisplayMetrics");
> screenDensity = (Integer)clazz.getField("densityDpi").get(clazz);
>
> "object is not an instance of the class"
>
> The error makes sense but I'm not sure how to correct it...

That would work if densityDpi were a static data member, as is the
case in my sample. In your case, the parameter to get() should be the
DisplayMetrics instance you obtained. DisplayMetrics itself existed
since API Level 1, so that's safe to obtain by normal methods.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to