user3256145 user3256145 - 16 days ago 7
Android Question

How to go move from one activity to a fragment in android?

I have this code to move from a Fragment MyTask extends Fragment to an Activity NewPage extends activity.

Intent i4=new Intent(getActivity(),NewPage.class);
startActivity(i4);


Now I want to go from NewPage.class back to my MyTask fragment.
How can I do that?

Answer

Use the finish() method in the Activity to close it.