How to get the ID of a fragment?

view full story

http://stackoverflow.com – First of all, I followed this tutorial to create an activity with an actionbar+tabs. What this implementation does is that it has a fragment_container (just a linear layout) in the main_activity layout and it replaces it with a fragment depending on what tab is selected. Now, I'm trying to add some fragment-to-activity communication but I'm getting a nullpointerexemption. Here's my code: com.mypackage.MAPFragment map_ = (com.mypackage.MAPFragment) getFragmentManager().findFragmentById(R.id.map); map_.ActivityToMapMethod(); The MAPFragment fragment inflates a xml layout that has a mapView (HowTos)