Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
单击通知时,android应用程序中未打开目标活动_Android_Notifications - Fatal编程技术网

单击通知时,android应用程序中未打开目标活动

单击通知时,android应用程序中未打开目标活动,android,notifications,Android,Notifications,此方法在我的服务中------>>> 公共类MyFirebaseMessagingService扩展了FirebaseMessagingService 单击通知时,我的目标活动(事件)未打开 //This method is only generating push notification //It is same as we did in earlier posts private void sendNotification(String messageBody) { Inten

此方法在我的服务中------>>> 公共类MyFirebaseMessagingService扩展了FirebaseMessagingService

单击通知时,我的目标活动(事件)未打开

//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());
}