This article is to close up the remaining of the first android article which is related to the activity and fragment in android program. In the first article I have shown you how to write a simple fragment program and in this article I will show you how to communicate between the activity and the fragment.
In order to get the fragment from the activity we will use the fragment manager.
FragmentManager fragmentManager = getFragmentManager();
Then search for that fragment
YourFragment yourFragment = (YourFragment) fragmentManager.findFragmentById(R.id.yourFragment);
Then in fragment we will use
to get the activity where the fragment is in.
Really simple procedure and now you can start coding and see how it works!