Does anyone explain to me why the icon of my notification is small and the notification when it "comes in" does not vibrate or make any sound? Thank you.
importandroid.app.Notification;importandroid.app.NotificationManager;importandroid.app.PendingIntent;importandroid.content.Context;importandroid.content.Intent;importandroid.graphics.BitmapFactory;importandroid.media.RingtoneManager;importandroid.net.Uri;importandroid.support.v4.app.NotificationCompat;importandroid.util.Log;importcom.google.firebase.messaging.RemoteMessage;publicclassMyFirebaseMessagingServiceextendscom.google.firebase.messaging.FirebaseMessagingService{privatestaticfinalStringTAG="MyFirebaseMsgService";
public MyFirebaseMessagingService(){
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String title = remoteMessage.getNotification().getTitle();
String message = remoteMessage.getNotification().getBody();
Log.d(TAG, "onMessageReceived: Message Received: \n" +
"Title: " + title + "\n" +
"Message: " + message);
sendNotification(title, message);
}
@Override
public void onDeletedMessages(){
}
private void sendNotification(String title, String messageBody) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setSmallIcon(R.mipmap.ic_launcher_round)
.setContentTitle("FCM Message")
.setContentText(messageBody)
.setAutoCancel(true)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = notificationBuilder.build();
note.defaults = Notification.DEFAULT_VIBRATE;
note.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationManager.notify(0, note);
}
}