1

When i call

NotificationManager mNotificationManager =
                                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

I get an error

The method getSystemService(String) is undefined for the type new BroadcastReceiver(){}

I'm not sure where I messed up... TIA

Arjun Krishnan
  • 359
  • 1
  • 6
  • 13

2 Answers2

4

Use like

NotificationManager mNotificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Sonali8890
  • 2,005
  • 12
  • 16
0

As far as i know, calling some methods that involves Context from a BroadcastReceiver isn't safe, as explained for Context.bindService() in this answer.

Community
  • 1
  • 1
Antoine Marques
  • 1,379
  • 1
  • 8
  • 16