i'm amateur in android and i want show notification with my app.
this is my code: but does not show notification.
please help me. thanks
public class MainActivity extends AppCompatActivity {
Button btn_ok;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_ok = findViewById(R.id.btn_ok);
btn_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCompat.Builder mbuilder = (NotificationCompat.Builder)
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher_background, 10)
.setContentTitle("Notification")
.setContentText("This is a notification for you");
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, mbuilder.build());
}
});
}
}