Skip to content

DzBasicActivity#54

Open
Gimasteev wants to merge 4 commits intoOtus-Android:masterfrom
Gimasteev:master
Open

DzBasicActivity#54
Gimasteev wants to merge 4 commits intoOtus-Android:masterfrom
Gimasteev:master

Conversation

@Gimasteev
Copy link

Прошу проверить домашнюю работу

android:exported="false" />
<activity
android:name=".Activity_A"
android:exported="true">
Copy link

Choose a reason for hiding this comment

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

@Gimasteev , тут не подходит стандартный режим запуска. Не получится выполнить задание 2.3:

По клику на кнопку “Open ActivityA” запустите ActivityA, таким образом, чтобы мы попали на существующий экземпляр  ActivityA и у него был вызван метод onNewIntent, независимо от того находится ActivityA наверху своего стека или нет

Вот тут есть удобная таблица по launchMode. Посмотрите, пожалуйста.

if (view is Button) {
// Создаем Intent для открытия другого Activity
val intent = Intent(this, Activity_B::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
Copy link

Choose a reason for hiding this comment

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

@Gimasteev, правильная попытка, но сам по себе этот флаг не работает. Нужно добавить FLAG_ACTIVITY_MULTIPLE_TASK. Тогда у вас, при запуске Б, будет в последних запущенных вот такая картинка
several tasks

// Создаем Intent для открытия другого Activity
val intent = Intent(this, Activity_A::class.java)
// Начинаем новое Activity
startActivity(intent)
Copy link

Choose a reason for hiding this comment

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

@Gimasteev, не выполняется задание 3.2. Оставил комментарий выше. Возможно, можно добиться того же эффекта с флагом FLAG_ACTIVITY_CLEAR_TOP


fun onClickListenerOpenDfromC(view: View){
val intent = Intent(this, Activity_D::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
Copy link

Choose a reason for hiding this comment

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

@Gimasteev, правильное решение, но нужно добавить еще один флаг FLAG_ACTIVITY_NEW_TASK

}

fun onClickListenerCloseStackAndGoA(view: View){
val intent = Intent(this, Activity_A::class.java)
Copy link

Choose a reason for hiding this comment

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

@Gimasteev, еще обратите внимание на функцию finishAffinity


fun onClickListenerCloseCAndStack(view: View){
val intent = Intent(this, Activity_B::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
Copy link

Choose a reason for hiding this comment

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

@Gimasteev, есть метод проще - не нужно ничего знать про другую активити. Чтобы завершить текущую и вернуться назад - достаточно вызвать метод finish

…сь по заданию 2.4 и 2.5. Вроде как сделал, но не понял как в трее висит таск, хотя я сделал очистку.
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

Comments