HOw 使通知管理器工作



当我打电话时

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

我收到错误

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

我不知道我在哪里搞砸了...蒂亚

使用 like

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

据我所知,从 BroadcastReceiver 调用一些涉及上下文的方法并不安全,正如本答案中Context.bindService()所解释的那样。

相关内容

最新更新