The following will work in Android 5.0 (Lollipop) and above:
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//for Android 5-7
intent.putExtra("app_package", getPackageName());
intent.putExtra("app_uid", getApplicationInfo().uid);
// for Android 8 and above
intent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName());
startActivity(intent);
Notes: This is not officially supported in Android 5-7, but it works just fine. It IS officially supported as of Android 8. This code is not backwards compatible with versions of Android before 5.0.
I merged the code of some of the answers above and added little edit, I have tested and it working fine on Android KitKat, Lollipop, Marshmallow, Nougat, Oreo and Pie, API level 19 - 28