Android App restarts after settings activity exits on some devices

56 views Asked by At

I have created an Android app and, when launching Settings Activity, on most devices after returning it goes back to the main app screen without restarting. On my Huawei P30 pro, for some reason, it restarts the original app. Why would I have such different behavior? I use AppCompatActivity which shows PreferenceFragmentCompat fragment

1

There are 1 answers

0
votopec On

Fixed it with:

supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
  

in OnCreate()

and then:

override fun onSupportNavigateUp(): Boolean {
    Log.d(TAG,"Navigate Up clicked")
    onBackPressed()
    return true
}

in the activity