当我打电话
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
我收到错误
The method getSystemService(String) is undefined for the type new BroadcastReceiver(){}
我不确定我搞砸了哪里...... TIA
答案 0 :(得分:4)
使用
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
答案 1 :(得分:0)
据我所知,调用某些涉及来自BroadcastReceiver的Context的方法并不安全,如Context.bindService()
in this answer所述。