Skip to content

DZ/Basic-Activities_1#30

Open
LexAndro3723 wants to merge 2 commits intoOtus-Android:masterfrom
LexAndro3723:master
Open

DZ/Basic-Activities_1#30
LexAndro3723 wants to merge 2 commits intoOtus-Android:masterfrom
LexAndro3723:master

Conversation

@LexAndro3723
Copy link

DZ/Basic-Activities_1

setContentView(R.layout.activity_activity)
}
override fun onStart() {
super.onStart()
Copy link

Choose a reason for hiding this comment

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

@LexAndro3723 , мне кажется, имеет смысл заводить все статические обработчики вью в onCreate. onStart вызывается, когда активити вот-вот покажется пользователю. И она может быть вызвана несколько раз - в начале и после onRestart. Зачем нам привязывать обработчик к кнопке несколько раз?

}
val button1 = findViewById<Button>(R.id.buttonSecondActivityD)
button1.setOnClickListener {
val intent = Intent(applicationContext, ActivityD::class.java)
Copy link

Choose a reason for hiding this comment

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

@LexAndro3723 , тут немного недоработано. По заданию, нужно очистить стек в текущей задаче. Для этого нужно воспользоваться флагами:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_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