I’m kind of new to Android programming, and i’m comming from a strong background of iOS programming.
I noticed a “weird” thing in the Android platform:
Some System-Services (like NotificationManager) are accessed through the method getSystemService() which accepts a string as a parameter and returns the desired class.
My question is, why did Google (or whoever designed this API) made it this way and did not make specific get method for each system service?
I think that making a separate method for each service is more robust and less error-prone. It also saves the need of casting, which is kind of “ugly” programming.
So what is the advantage of using retriving-by-name?
I think this was done for abstract generality and the ability to add more as needed with next versions without disrupting the schema with new method names, parameters, etc.