I'm developing an android application that is dependent on maps and location.
I have ActivityA
that contains fragmentA
.
I have an alert that request the user to turn on location service inside fragmentA
.
When the user accept to turn on the service, I want my code to continue running, otherwise finish()
the app. So I should use OnActivityResult()
to know what did the user pressed in the alert.
My problem is that when the user accept to turn on Location, the function OnActivityResult()
is launched in the activity and not in the fragment.
I read about this problem, people are suggesting to call startActivityForResult(...)
rather than startActivity(...)
.
But I can't start the activity from an inside fragment because this will lead to crash problems regarding data that are in the intent.
So any one has any suggestions ?
This is the function that requests Location in fragmentA
.