I have the following simple class that I would like to use to notify user of incoming messages (I will evolve it as the app goes). But for now, in the last line, there is the following error and I can't run it:
Cannot resolve method build()
Here is the code:
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
public class UserNotificationActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void triggerNoti() {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!");
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(001, mBuilder.build());
}
}
I've tried this solution but doesn't make any change
What am I doing wrong ?!
P.S.: Target (& min) sdk = 21