Skip to content

Activities 01#35

Open
Serovatova wants to merge 5 commits intoOtus-Android:masterfrom
Serovatova:activities_01
Open

Activities 01#35
Serovatova wants to merge 5 commits intoOtus-Android:masterfrom
Serovatova:activities_01

Conversation

@Serovatova
Copy link

No description provided.

<activity
android:name=".MainActivityA"
android:exported="true"
android:launchMode="singleInstance">
Copy link

Choose a reason for hiding this comment

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

@Serovatova , сингл-инстанс тут не подойдет, потому что в первом задании написано:

при этом предусмотрите возможность открывать другие Activity в том же стеке где расположена ActivityA

А вот, что написано в документации:

The "singleInstance" mode also differs from "singleTask" and "singleInstancePerTask" in only one respect: an activity with the "singleTask" or "singleInstancePerTask" launch mode lets other activities, necessarily "standard" and "singleTop" activities, be part of its task.

A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It must be the only activity in the task. If it starts another activity, that activity is assigned to a different task, as if FLAG_ACTIVITY_NEW_TASK were in the intent.

<activity
android:name=".MainActivityC"
android:exported="false"
android:launchMode="singleTask">
Copy link

Choose a reason for hiding this comment

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

тут нам сингл-таск, вроде бы, не нужен. Для запуска в отдельном таске можно или taskAffinity применить, или флажками вытащить активити Б на другой таск, а дальше уже оно само

}
startActivity(intent)
}
}
Copy link

Choose a reason for hiding this comment

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

Я б тут советовал завести метод onNewIntent, чтобы легче было проверить третье задание

val intent = Intent(this, MainActivityC::class.java)
startActivity(intent)
}
button2.setOnClickListener {
Copy link

Choose a reason for hiding this comment

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

Кнопки перехода на активити А тут быть не должно

}

startActivity(intent)
}
Copy link

Choose a reason for hiding this comment

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

Отсутствует преход на активити А с закрытием стека


val button = findViewById<Button>(R.id.button_clear_D)

button.setOnClickListener {
Copy link

Choose a reason for hiding this comment

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

В активити Д по заданию нет кнопок



button2.setOnClickListener {
val intent = Intent(this,MainActivityB::class.java).apply {
Copy link

Choose a reason for hiding this comment

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

По заданию, явного перехода на активити Б с активити Ц нет. Должна быть кнопка завершения активити Ц

val button = findViewById<Button>(R.id.button_activity_B)
button.setOnClickListener {
val intent = Intent(this, MainActivityB::class.java).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or 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.

Неверный режим запуска активити. Новый таск не создается. Почитайте документацию на FLAG_ACTIVITY_NEW_TASK

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