Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] kotlin – Why is the Android onCreate() method not called when the AVD is rotated?

Posted on November 11, 2022 By

Solution 1 :

It’s hard to help you without seeing your code. But check that is this line available in your code.

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Solution 2 :

Maybe be you don’t activate rotation in the top panel of your simulator.

Problem :

My AndroidManifest.xml does not include anything that would cause this (that I know of).

I.e. it does not include:

android:configChanges=”orientation”

Android Version: Chipmunk 2021.2.1 Patch 1

class MainActivity : AppCompatActivity() {
    internal lateinit var tapMeButton: Button
    internal lateinit var gameScoreTextView: TextView
    internal lateinit var timeLeftTextView: TextView
    internal var score: Int = 0
    internal var gameStarted = false
    internal lateinit var countDownTimer: CountDownTimer
    internal val initialCountDown: Long = 5000
    internal val countDownInterval: Long = 1000

    companion object {
        private val TAG = MainActivity::class.java.simpleName
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        Log.d(TAG, "onCreate called. Score is $score")

        tapMeButton = findViewById(R.id.tapMeButton)
        gameScoreTextView = findViewById(R.id.gameScoreTextView)
        timeLeftTextView = findViewById(R.id.timeLeftTextView)

        tapMeButton.setOnClickListener { view ->
            if (!gameStarted) {
                startGame()
            }
            incrementScore()
        }

        resetGame()
    }

Comments

Comment posted by Gavin Wright

Are you sure you’ve correctly overridden

Comment posted by stackoverflow.com/q/8515936/6892294

See this discussion to understand what is happening here:

Comment posted by mstucki7

I added onCreate() to original post. Thanks!

READ  [FIXED] reactjs - making react native to use a Android simulator located at other computer
Powered by Inline Related Posts
Android Tags:android, kotlin, oncreate, rotation

Post navigation

Previous Post: [FIXED] android – Overlapping items in RelativeLayout with ImageView and TextView
Next Post: [FIXED] android – Unable to instantiate application com.company.app.MainApplication: java.lang.ClassNotFoundException React Native Expo

Related Posts

[FIXED] android – Runtime error for suspend function when implementing launchIn Android
[FIXED] android – video on infinite scroll list Android
[FIXED] android – Flutter build fails due to Audio Wave forms package Android
[FIXED] android – Google play store alpha and beta tracks Android
[FIXED] android – how to save an object in object in real-time database, Firebase (kotlin) Android
[FIXED] android – navController.navigate(fragmentAId) vs navController.navigate(action_fragmentA_to_fragmentB)? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme