我的应用程序被杀死,并使用FirebaseMessagingService从Firebase接收了推送通知。在推送通知中,单击我要打开应用程序

时间:2018-06-19 14:58:03

标签: android

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

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

最终PendingIntent resultPendingIntent =                 PendingIntent.getActivity(                         mContext,                         0,intent,PendingIntent.FLAG_UPDATE_CURRENT);

       Notification notification;
    notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
            .setAutoCancel(true)
            .setContentTitle(title)
            .setContentIntent(resultPendingIntent)
            .setSound(alarmSound)
            .setStyle(inboxStyle)
            .setWhen(getTimeMilliSec(timeStamp))
            .setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
            .setContentText(message)
            .build();

    NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(AppConstants.NOTIFICATION_ID, notification);

0 个答案:

没有答案