我的代码用于使用SherlockFragment的应用程序中的通知:
代码:
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);错误:
错误:创建常量NOTIFICATION_SERVICE
发布于 2013-07-01 18:36:15
getSystemService()和NOTIFICATION_SERVICE是在Context上定义的。Activity继承了Context,但SherlockFragment没有。
将代码更改为:
NotificationManager nm = (NotificationManager)getActivity().getSystemService(Context.NOTIFICATION_SERVICE);https://stackoverflow.com/questions/17411328
复制相似问题