Carson
Carson

Reputation: 113

Cannot resolve symbol 'Notification'

I have the following method to create a notification in a brand new android studio project in the MainActivity.java:

public void getNot(View v){
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notification_icon)
            .setContentTitle("My notification")
            .setContentText("Hello World!");
}

But it gets a "Cannot resolve symbol 'NotificationManager'" error and similar ones for any other notification related objects. Why does this not work? It's a brand new project.

Upvotes: 0

Views: 3783

Answers (1)

zihadrizkyef
zihadrizkyef

Reputation: 1941

try to put the cursor inside the "NotificationManager" then press Alt+Enter then select import class/package

Upvotes: 1

Related Questions