Can't use the public static method?

This is confusing. I look at the source code of Android 2.2.2_r1 for the NotificationManager class , and I see a method getService()that is defined as publicand static. However, the eclipse tells me:

The getService () method is undefined for the NotificationManager type on the line

 Object o = NotificationManager.getService();

My project is built against Android 2.2 / API level 8. I tried to use reflection to see method names and modifiers, and, of course, I came back

public static getService

Am I missing something? Why does the eclipse tell me that this method does not exist?

+5
source share
1 answer

You will find a very detailed answer in this post .

: android.jar, (, , ). , Android.


, , . NotificationManager getSystemService :

NotificationManager nm = (NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);

context (, ).

+5

All Articles