Android端自定义消息接收到显示Notification点击没有效果

Messy
2018-05-25 01:21 1.4k 0

手机接收到自定义消息后 如果APP已经退出就显示Notification,但是在点击Notification的时候没有效果,不会启动APP,

Intent intent = new Intent(context, MainActivity.class);intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.putExtra(NotificationUtil.INTENT_DATA, data);
 NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.logo));
        builder.setSmallIcon(R.mipmap.logo);
        builder.setContentIntent(pendingIntent);
        PendingIntent hangIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        builder.setFullScreenIntent(hangIntent, true);
        builder.setAutoCancel(true);
        NotificationManager notificationManager = (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(2, builder.build());

1个回答

热门排序