I have one activity and fragment inside, I open second activity for result from my fragment :
startActivityForResult(LocationSelectorActivity.newIntent(context!!), START_LOCATION_SELECTOR)
If i force activity for die when user will leave it ( from developer option) , after back click from my second activity onViewCreated is called twice in my fragmetn
override fun onViewCreated(view: View, savedInstanceState: Bundle?)
Here is how I add fragment :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addFragment(MyFragment(), R.id.content_frame)
}
fun AppCompatActivity.addFragment(fragment: Fragment, frameId: Int) {
supportFragmentManager.inTransaction { add(frameId, fragment) }
}