-
Notifications
You must be signed in to change notification settings - Fork 57
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
base: master
Are you sure you want to change the base?
Activity #1 #34
Conversation
startActivity(intent) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NanaOz , я бы использовал тут режим запуска singleTask. Почему:
- Задание 1:
при этом предусмотрите возможность открывать другие Activity в том же стеке где расположена ActivityA
- Задание 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NanaOz, отлично! Это совместимый метод. Но рекомендую еще посмотреть метод finishAffinity
No description provided.