Better solution: All services should be defined via interface, with nary an implementation class to be seen. Specifying an implementation class, as the current spec does, does not add value -- it removes it.
Workaround: Define your own interface class, and your own method that calls getSystemService, and wraps the return value in an instance if your interface, which delegates to the system one. Then, to generate a mock one, generate a mock of your interface. Don't use the system's implementation class in your code, but rather your interface, and you're fine. This is easy. What's hard is doing this N times for all the places this simple design rule is not followed in the system, where N is extremely large. But you can at least automate your wrapper object implementations using the java Proxy mechanism and reflection, for everything but performance-critical objects. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en