Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity #1 #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Activity #1 #34

wants to merge 3 commits into from

Conversation

NanaOz
Copy link

@NanaOz NanaOz commented Nov 3, 2023

No description provided.

startActivity(intent)
}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NanaOz, добавьте сюда, пожалуйста, переопределение метода onNewIntent с каким-нибудь логированием типа:

        Log.w("A", "New intent")

Таким образом, вы сможете проверить выполнение задания 3

<activity
android:name=".ActivityA"
android:exported="true">
<intent-filter>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NanaOz , я бы использовал тут режим запуска singleTask. Почему:

  1. Задание 1: при этом предусмотрите возможность открывать другие Activity в том же стеке где расположена ActivityA
  2. Задание 3: По клику на кнопку “Open ActivityA” запустите ActivityA, таким образом, чтобы мы попали на существующий экземпляр ActivityA и у него был вызван метод onNewIntent

В таком случае, мы можем и создавать активити выше по стеку в этой задаче и возвращаться в наш экземплят. Синглтоп, что вы используете во флагах вернется в тот же экземпляр только если он на верху стэка. А если он чем-то накрыт, то будет пересоздан. Вот тут, мне кажется, неплохая статейка с примерами

// Обработка нажатия на кнопку "Close Stack"
val intent = Intent(this, ActivityA::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NanaOz, отлично! Это совместимый метод. Но рекомендую еще посмотреть метод finishAffinity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants