Thanks for your help Mark.  For anyone that's interested, here's a
code snippet.

        private static String manufacturer = null;
        public static String getDeviceManufacturer() throws Exception {
                // use reflection to get device manufacturer safely.

                // ANDROID1.6
                // android.os.Build.MANUFACTURER

                if (manufacturer != null) {
                        return manufacturer;
                }

                try {
                        Class<android.os.Build> buildClass = 
android.os.Build.class;
                        Field field = buildClass.getField("MANUFACTURER");
                        manufacturer = (String) field.get(new 
android.os.Build());
                } catch (NoSuchFieldException e) {
                        manufacturer = "(unavailable)";
                } catch (Exception e) {
                        manufacturer = "error";
                }
                return manufacturer;
        }

and it seemed to work.

On Nov 11, 12:04 pm, Mark Murphy <[email protected]> wrote:
> sdphil wrote:
> > hm...  looks like I should use this --
> >http://developer.android.com/reference/java/lang/reflect/Field.html
>
> Yes. The only tricky part may be getting it for a static. I haven't done
> tons of reflection work, so I don't have examples to show you of this
> specific problem.
>
> On the plus side, you can do the reflection work itself in a static
> context, so you only go through the reflection once.
>
> > also, I don't think a try/catch will work - the java pre-verifier will
> > choke before it gets to running it... eh?
>
> Yup!
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _Beginning Android_ from Apress Now 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