0

我的代碼是在我的應用程序的通知,告知使用SherlockFragment:NotificationManager在SherlockFragment

代碼:

NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); 

錯誤:

ERROR: Create constant NOTIFICATION_SERVICE

回答

3

getSystemService()NOTIFICATION_SERVICE定義上ContextActivity繼承自Context,但SherlockFragment沒有。

你的代碼更改爲:

NotificationManager nm = (NotificationManager)getActivity().getSystemService(Context.NOTIFICATION_SERVICE); 
+0

感謝的人它的作品! – user2528081

相關問題