Monday, June 13, 2011

[android-developers] design of accessing to system service

I still can't understand some aspects of Android API design or reason
to use this design.

For example why Android use this:

AlarmManager am =
(AlarmManager)getSystemService(Context.ALARM_SERVICE);

instead of much easier:

AlarmManager am = getSystemService(AlarmManager.class);

AlarmManager.class is possible convert to String a use as key in the
same way as constant. Android also support generics.

Developer also must remember, that Context.ALARM_SERVICE constant will
provide AlarmManager instance. Constant has different name that
class :-(

Or first one is so much faster?

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

No comments:

Post a Comment