Android Notification "Cannot resolve method 'build ()' from ABS snippet

I am trying to show a basic notification from a fragment in an ActionBarSherlock layout. I was following the tutorial here , as well as the one on the Android Developer pages, but I get the error "Can not resolve method" () 'on the last line. I 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?

+1


source to share


1 answer


It worked with me for both build () and getNotification (). FYI, Notification.Builder.build () is API level 16, so check your target. Also check your import and build paths and clean up the project. If the problem persists, try using a different android-support-v4.jar file inside libs.



Hope it helps.

+1


source







All Articles