Skip to content Skip to sidebar Skip to footer

Onviewcreated Called Twice

I have one activity and fragment inside, I open second activity for result from my fragment : startActivityForResult(LocationSelectorActivity.newIntent(context!!), START_LOCATION_S

Solution 1:

The problem rises in following line:

startActivityForResult(LocationSelectorActivity.newIntent(context!!), START_LOCATION_SELECTOR)

LocationSelectorActivity.newIntent(context) must be replaced by:

Intentintent=newIntent(/*your desirable configiration*/);
getActivity().startActivityForResult(intent, START_LOCATION_SELECTOR);

or

Intentintent=newIntent(/*your desirable configiration*/);
startActivityForResult(intent, START_LOCATION_SELECTOR);

then in your host activity or the fragment override onActivityResult() method

Post a Comment for "Onviewcreated Called Twice"