Намеренные дополнения на Сервис-активность - PullRequest
0 голосов
/ 27 сентября 2019

У меня есть Активность и Сервис.В сервисе я создаю уведомление, и, если оно касается, открывается действие.

Intent notificationIntent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
        Bundle extras = new Bundle();
        extras.putString(MainActivity.SELECTED_FRAGMENT,"GameFragment");
        extras.putParcelable(GameFragment.GAME_ARG,route);
        notificationIntent.putExtras(extras);
        Log.d("JON notification intent","Elements: " + notificationIntent.getExtras().size());
        PendingIntent pendingIntent =
                PendingIntent.getActivity(this, 0, notificationIntent, 0);
        Notification notification =
                new Notification.Builder(this, channelId)
                        .setContentTitle(getText(R.string.app_name))
                        .setContentText(getText(R.string.app_name))
                        .setSmallIcon(R.drawable.ic_stat_orbel_jokuek)
                        .setContentIntent(pendingIntent)
                        .setTicker(getText(R.string.app_name))
                        .build();

        startForeground(1, notification);

Проблема в том, что при методе onCreate of Activity:

if (getIntent().getExtras() != null) {
        Log.d("JON intent size","Elements: " + getIntent().getExtras().size());
    }

Я получаю только 1 дополнительный, но я добавляю два дополнительных в намерение уведомления.Любая помощь или смысл ??

Спасибо

1 Ответ

1 голос
/ 27 сентября 2019

В ответе использовалось PendingIntent.FLAG_UPDATE_CURRENT для функции PendingIntent.getActivity ().

...