Skip to content

Instantly share code, notes, and snippets.

@jobinlawrance
Last active November 2, 2020 05:53
Show Gist options
  • Save jobinlawrance/e341503060e1f8beef12edf03cd85c31 to your computer and use it in GitHub Desktop.
Save jobinlawrance/e341503060e1f8beef12edf03cd85c31 to your computer and use it in GitHub Desktop.
A fragment that crashes on recreation
class MainActivity : AppCompatActivity() {
val mainFragment = MainFragment("Ready to crash")
override fun onCreate(savedInstanceState: Bundle?) {
// the usual stuff
supportFragmentManager.beginTransaction()
.add(R.layout.fragmentContainerView, mainFragment)
.commit()
}
}
class MainFragment(val textToDisplay: String) : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// Logic related to using $textToDisplay
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment