-2

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()
    }
mstucki7
  • 1
  • 2
  • Are you sure you've correctly overridden `onCreate()`? At least show us what your `onCreate()` looks like. It's hard for us to help when you pose a seemingly impossible scenario but give us no code. – Gavin Wright Jun 11 '22 at 04:13
  • See this discussion to understand what is happening here: https://stackoverflow.com/q/8515936/6892294 – DocJ457 Jun 11 '22 at 04:25
  • I added onCreate() to original post. Thanks! – mstucki7 Jun 12 '22 at 13:05

2 Answers2

0

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);
0

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

Anthone
  • 2,156
  • 21
  • 26