Ниже приведен мой код для ожидаемого намерения для уровня Android API больше 8:
Intent intent = new Intent(context, NotificationActivityBDO.class);
intent.putExtra("requestNotifyData", requestData);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent =
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
String CHANNEL_ID = chanelID;// The id of the channel.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String programId = BankBrandingUtil.getProgramIdForBranding(context);
Log.d(TAG, "programId: " + programId);
icon = R.drawable.pn_icon;
CharSequence name;
name = "Transactions";// The user-visible name of the channel.
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
mChannel.setDescription(context.getResources().getString(R.string.lbl_iap_notification_channel_desc));
getNotificationManager(context).createNotificationChannel(mChannel);
}
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher);
//Notification.Builder builder = new Notification.Builder(context);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID);
builder.setContentIntent(contentIntent);
builder.setLargeIcon(bitmap);
builder.setSmallIcon(icon);
builder.setTicker(tickerText)
.setContentTitle(title)
.setContentText(text);
builder.setOnlyAlertOnce(true);
builder.setAutoCancel(true);
builder.setWhen(when);
Notification notification = builder.build();
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
Log.v(TAG, "notifiTag: " + notifiTag);
Log.v(TAG, "notifiId: " + notifiId);
getNotificationManager(context).notify(notifiTag, notifiId, notification);
В NotificationActivityBDO
я получаю дополнения, как показано ниже:
Bundle extras = activity.getIntent().getExtras();
if (extras != null) {
requestData = (RequestData) extras.getSerializable("requestNotifyData");
}
Над кодом работаетштраф ниже 8, и недавно мое устройство получило обновление до пирога (версия Android 9), уведомление отображается, и при нажатии дополнительные функции запуска отображаются как null
.
Независимо от приложения в фоновом режиме или на переднем плане I 'я получаю requestMoneyData
как null
, и при отладке я вижу дополнения как "пустую посылку", и это произошло только в версии Android 9, и она работает нормально ниже Android 9.
Любая помощь приветствуется для разрешенияВыше проблема.