Skip to content

Instantly share code, notes, and snippets.

@ogaclejapan
Last active September 10, 2018 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogaclejapan/39010bbbfbd9d53574a32bcb72cd47c9 to your computer and use it in GitHub Desktop.
Save ogaclejapan/39010bbbfbd9d53574a32bcb72cd47c9 to your computer and use it in GitHub Desktop.
onStop() is not called on Nougat 7.0 - repeat next activity start and backpress several times
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d("TEST", "onCreate: $this")
setContentView(R.layout.activity_main)
findViewById<View>(R.id.test).setOnClickListener { test() }
}
override fun onStart() {
super.onStart()
Log.d("TEST", "onStart: $this")
}
override fun onResume() {
super.onResume()
Log.d("TEST", "onResume: $this")
}
override fun onPause() {
super.onPause()
Log.d("TEST", "onPause: $this")
}
override fun onStop() {
super.onStop()
Log.d("TEST", "onStop: $this")
}
override fun onDestroy() {
super.onDestroy()
Log.d("TEST", "onDestroy: $this")
}
private fun test() {
startActivity(
Intent(this, MainActivity::class.java),
ActivityOptionsCompat.makeSceneTransitionAnimation(this).toBundle()
)
}
}
# emulator: system-images;android-24;google_apis;x86_64
// launch
onCreate: com.example.MainActivity@a973caf
onStart: com.example.MainActivity@a973caf
onResume: com.example.MainActivity@a973caf
onPause: com.example.MainActivity@a973caf
// start activity
onCreate: com.example.MainActivity@e8f0ea1
onStart: com.example.MainActivity@e8f0ea1
onResume: com.example.MainActivity@e8f0ea1
onPause: com.example.MainActivity@e8f0ea1
// backpress
onResume: com.example.MainActivity@a973caf
onStop: com.example.MainActivity@e8f0ea1
onDestroy: com.example.MainActivity@e8f0ea1
// start activity
onPause: com.example.MainActivity@a973caf
onCreate: com.example.MainActivity@fb05a03
onStart: com.example.MainActivity@fb05a03
onResume: com.example.MainActivity@fb05a03
// backpress
onPause: com.example.MainActivity@fb05a03
onResume: com.example.MainActivity@a973caf
onStop: com.example.MainActivity@fb05a03
onDestroy: com.example.MainActivity@fb05a03
// backpress
onPause: com.example.MainActivity@a973caf
onStop: com.example.MainActivity@a973caf
onDestroy: com.example.MainActivity@a973caf
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowEnterTransition">@android:transition/slide_bottom</item>
<item name="android:windowReturnTransition">@android:transition/slide_bottom</item>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment