-
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
Activities 01 #35
base: master
Are you sure you want to change the base?
Activities 01 #35
Conversation
app/src/main/AndroidManifest.xml
Outdated
<activity | ||
android:name=".MainActivityA" | ||
android:exported="true" | ||
android:launchMode="singleInstance"> |
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.
@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.
app/src/main/AndroidManifest.xml
Outdated
<activity | ||
android:name=".MainActivityC" | ||
android:exported="false" | ||
android:launchMode="singleTask"> |
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.
тут нам сингл-таск, вроде бы, не нужен. Для запуска в отдельном таске можно или taskAffinity применить, или флажками вытащить активити Б на другой таск, а дальше уже оно само
} | ||
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.
Я б тут советовал завести метод onNewIntent
, чтобы легче было проверить третье задание
val intent = Intent(this, MainActivityC::class.java) | ||
startActivity(intent) | ||
} | ||
button2.setOnClickListener { |
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.
Кнопки перехода на активити А тут быть не должно
} | ||
|
||
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.
Отсутствует преход на активити А с закрытием стека
|
||
val button = findViewById<Button>(R.id.button_clear_D) | ||
|
||
button.setOnClickListener { |
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.
В активити Д по заданию нет кнопок
|
||
|
||
button2.setOnClickListener { | ||
val intent = Intent(this,MainActivityB::class.java).apply { |
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.
По заданию, явного перехода на активити Б с активити Ц нет. Должна быть кнопка завершения активити Ц
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 |
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.
Неверный режим запуска активити. Новый таск не создается. Почитайте документацию на FLAG_ACTIVITY_NEW_TASK
No description provided.