jeudi 21 juillet 2016

Launch second activity from Fragment A using parent actiivity of Fragment A

I am standing before an interesting question. Is there a way (library, code, some hack) to solve my question ? Situation is like this:

We have Activity A with it's listViewFragment A. When I click on item of that listView I need to launch Activity B. I do this by calling:

getActivity().startActivity(intent);

But that may lead to memory leaks or sometimes the getActivity() returns null because fragment is not attached to it's activity.

I imagine making some interface and calling it from there but I don't really know how to implement this idea.

Aucun commentaire:

Enregistrer un commentaire