I cannot generate a notification (in the notification area) from an IntentService . I get a NullPointerException by getting a NotificationManager . The problem is Context.
06-01 16:46:05.910: ERROR/AndroidRuntime(14745): Caused by: java.lang.NullPointerException 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): at android.content.ContextWrapper.getSystemService(ContextWrapper.java:363) 06-01 16:46:05.910: ERROR/AndroidRuntime(14745): at com.Android.Main1.FileUploaderService.<init>(FileUploaderService.java:71)
Line of code:
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
I tried getApplicationContext() , getBaseContext() , but to no avail.
Can someone please let me know what the problem is? How to create notifications from IntentService?
Additional Information:
I also have a Service in my application, and notifications from there work fine. IntentService does not start Activity; it is launched by the Service.
source share