2014-02-25 59 views
1

當我打電話如何讓通知管理員工作?

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

我得到一個錯誤

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

我不知道在那裏我搞砸了...... TIA

+0

你在哪裏調用這個語句,在broadcastReceiver? – Coderji

回答

4

使用像

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

據我所知,調用一些涉及B的上下文的方法roadcastReceiver不安全,如Context.bindService()in this answer所述。