Ouvrir Activité spécifique lors de la notification d'un clic dans la FCM

Je suis en train de travailler sur une Application dans laquelle je suis tenu d'afficher les notifications.
Pour les avis, je suis à l'aide de FireBase Messagerie en Nuage (FCM).
Je suis en mesure d'obtenir Notification lorsque l'application est en arrière-plan.

Mais quand je clique sur une notification, il vous rediriger vers home.java page. Je veux rediriger vers Notification.java page.

Donc,s'il vous plaît dites-moi comment spécifier Activité sur le Clic de la notification.
Je suis l'aide de deux services:

1.)MyFirebaseMessagingService

2.)MyFirebaseInstanceIDService

C'est mon exemple de code pour onMessageReceived() méthode dans MyFirebaseMessagingService classe.

public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "FirebaseMessageService";
Bitmap bitmap;
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom());
//Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
//Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
//Also if you intend on generating your own notifications as a result of a received FCM
//message, here is where that should be initiated. See sendNotification method below.
}
/**
* Create and show a simple notification containing the received FCM message.
*/
private void sendNotification(String messageBody, Bitmap image, String TrueOrFalse) {
Intent intent = new Intent(this, Notification.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("Notification", TrueOrFalse);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setLargeIcon(image)/*Notification icon image*/
.setContentTitle(messageBody)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(image))/*Notification with Image*/
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
/*
*To get a Bitmap image from the URL received
* */
public Bitmap getBitmapfromUrl(String imageUrl) {
try {
URL url = new URL(imageUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(input);
return bitmap;
} catch (Exception e) {
//TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
retirer la "notification" de votre fcm charge utile et il fonctionnera
Merci pour votre réponse!
Tu veux dire à dire, supprimer getNotification() à partir de getNotification().getBody();??
non, pas du tout. Lire ce stackoverflow.com/a/37876727/1843331
Monsieur! Je suis la réception de la notification corrcetly, pas de problème!! Je veux ouvrir activité Notification.java lorsque l'on clique sur réception de la notification. Comment spécifier dans le code.

OriginalL'auteur Arman Reyaz | 2016-11-21