Use NotificationManager in a class that is not Activity

1

I'm having a problem and I'm not getting any better. The problem is this: I have a Fragment in my app, and I want to trigger a notification from it. The line I'm having problems with is this: NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

The error is in getSystemService() , the IDE tells me that "The getSystemService(String) method is undefined for type MinhaClasseFragment "

I have tried to get and pass contexts, until I use Context receiving getActivity() and nothing.

I searched the web and found nothing that would help me. What to do?

    
asked by anonymous 22.07.2014 / 20:38

1 answer

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

Try doing it straight.

    
22.07.2014 / 21:17