Skip to content Skip to sidebar Skip to footer

How To Call Activity Class From Fragment

I am working with Navigation Drawer and i want to call testActivity.java class when someone click on a item that is in the sliding menu.Currently my MainActivity.java calss is call

Solution 1:

In fragment you can access its parent FragmentActivity instance using getActivity(). And since that instance is an activity, so using that you can call another activity simply.

Intent myIntent = new Intent((ParentActivity)getActivity(), YourOtherActivity.class);
(ParentActivity)getActivity().startActivity(myIntent); 

Post a Comment for "How To Call Activity Class From Fragment"