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

Activities 01 #35

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

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