How to override onCreate method in kotlin in android studio

  • Thread starter Thread starter Android Central Question
  • Start date Start date
A

Android Central Question

Hello I am making a app in which when main activity opens a lotte animation plays as a button and when i click on that animation (button) then activity 2 opens and plays a video and when the video get completes i called main activity again using intent, so when main activity opens again i want that now that animation button hides.

I tried to write override onresume and i also tried override onrestart and then i wrote

override fun onRestart() {
super.onRestart()
binding.btnanimation.visibility = View.INVISIBLE
}
but when i do that then when activity opens in starting then also that button animation get hides, but i want that when app opens it must be visible as its called inside oncreate

my onCreate code something like this

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityMainBinding.inflate(layoutInflater)

requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)

setContentView(binding.root)

binding.btnanimation.visibility = View.VISIBLE
So what mistake i am doing and how to fix that ?
 

Forum statistics

Threads
954,592
Messages
6,962,111
Members
3,163,078
Latest member
marcociot