-
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 #50
base: homeworks/activities_01
Are you sure you want to change the base?
Activity 1 #50
Conversation
app/src/main/AndroidManifest.xml
Outdated
<activity | ||
android:name=".DActivity" | ||
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.
@RubaN0id, мне кажется, singleTask тут лишний. Во втором стеке активити у нас просто ложатся друг на друга. Или есть другие соображения?
android:name=".BActivity" | ||
android:exported="false" | ||
android:launchMode="singleTask" /> | ||
<activity |
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.
@RubaN0id, singleInstance тут не подойдет, потому что делает невозможным выполнение пункта 2.1:
при этом предусмотрите возможность открывать другие Activity в том же стеке где расположена ActivityA
Вот документация по флагам. Там есть удобная табличка.
val bButton: Button = findViewById(R.id.button_to_B) | ||
bButton.text = getString(R.string.open_activity_b) | ||
bButton.setOnClickListener { | ||
startActivity(Intent(this, BActivity::class.java)) |
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_MULTIPLE_TASK и FLAG_ACTIVITY_NEW_TASK.
Если все правильно настроено, то в списке последних запущенных вы явно увидите два стека - с А и Б
setContentView(R.layout.activity_c) | ||
val dButton: Button = findViewById(R.id.button_to_D) | ||
dButton.setOnClickListener { | ||
finishAffinity() |
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 и FLAG_ACTIVITY_CLEAR_TASK.
Это так, на всякий случай. Кроме того, finishAffinity не работает на старых андроидах. Надеюсь, не придется с ними столкнуться :)
No description provided.