以下是生成内联通知的代码,一切正常,但我不想显示MessageReply.class。
当前问题:出现白屏时调用待处理意图 发送消息时。
必需的结果:没有像whatsapp内联那样的白屏工作 通知。
void buildNotification(String messageValue) {
Intent intent = new Intent(this, Test.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(Consts.EXTRA_MESSAGE, messageValue);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(Consts.GCM_NOTIFICATION)
.setAutoCancel(true)
.setContentIntent(contentIntent)
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigTextStyle().bigText(messageValue))
.setContentText(messageValue)
.addAction(buildReplyFromNotification(extras));
Notification notification = mBuilder.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
private NotificationCompat.Action buildReplyFromNotification(Bundle data) {
String replyLabel = getResources().getString(R.string.reply_label);
RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY).setLabel(replyLabel).build();
// Create the reply action and add the remote input.
return new NotificationCompat
.Action
.Builder(R.drawable.ic_send, getString(R.string.reply_label), buildReplyPendingIntent(data))
.addRemoteInput(remoteInput)
.build();
}
private PendingIntent buildReplyPendingIntent(Bundle messageValue) {
Intent intent = new Intent(this, MessageReply.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(Consts.EXTRA_DIALOG_ID, messageValue.getString("dialog_id"));
return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
答案 0 :(得分:0)
尝试使用该活动的主题com.journeyapps:zxing-android-embedded