target activity not opening in android app on click of notification

时间:2016-08-31 18:41:57

标签: android notifications

This method is inside my service ----->>>> public class MyFirebaseMessagingService extends FirebaseMessagingService

my target activity (Event) is not opening when i m clicking on notification.

//This method is only generating push notification
//It is same as we did in earlier posts 
private void sendNotification(String messageBody) {

    Intent intent = new Intent(getApplicationContext(), Events.class);

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
            .setSmallIcon(R.mipmap.djchc_logo)
            .setContentTitle("Notification")
            .setContentText(messageBody)
            //.setAutoCancel(true)
            .setSound(defaultSoundUri);
            //.setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, notificationBuilder.build());
}

0 个答案:

没有答案