I want to play custom notification tone on firebase onMessage receive method, custom sound play only when the app is running, when app destroys system notification default sound play, I want to play custom notification when app destroyed or mobile locked firebase onMessage receive method.
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
Uri sound = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" + R.raw.door_bell);
RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(), RingtoneManager.TYPE_RINGTONE, sound);
Notification mNotification = new Notification.Builder(this)
.setContentTitle("New Post!")
.setContentText("Here's an awesome update for you!")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pIntent)
.addAction(R.mipmap.ic_launcher, "View", pIntent)
.addAction(0, "Remind", pIntent)
.setSound(sound)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(0, mNotification);
}
startActivity(new Intent(getApplicationContext(), MainActivity.class));