I am attempting to show a basic notification from a fragment in an ActionBarSherlock layout. I have been following the tutorial here as well as the one on the Android Developer pages, but I am getting the error 'Cannot resolve method 'build()' on the last line. I have imported android.support.v4.app.NotificationCompat
and .app.NotificationManager
public void createNotification(){
NotificationManager mNotificationManager = (NotificationManager)getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getActivity());
mBuilder.setSmallIcon(R.drawable.icon);
mBuilder.setContentTitle("Title");
mBuilder.setContentText("Text");
mBuilder.setTicker("Ticker");
mNotificationManager.notify(1,mBuilder.build());
}
If I change the last line to mNotificationManager.notify(1,mBuilder.getNotification());
it works. Why is this?
It worked with me for both build() and getNotification() . FYI , Notification.Builder.build() is API level 16 so check your target. Also check your imports and build paths and clean the project. If the problem persists try another android-support-v4.jar inside libs may be its corrupted.
Hope this helps.