this question has already been asked. However, Fragment is a portion of UI. A fragment relies on an activity, which can handle as many fragments as needed.
I don't think that you absolutely have to limit yourself to having a single activity only. Though, that pattern (1 activity + N fragments) proved useful to me. In my app, a simple quiz game, each of the fragments capture user actions and trigger async activity calls by the means of callbacks.
Example:
// Implements the main view of the app (home page)
public class HomeFragment extends Fragment {
/**
* A pointer to the current callbacks instance (an Activity).
*/
private HomeMenuCallbacks callbacks;
/**
* Callbacks interface (implemented by the Activity)
*/
public static interface HomeMenuCallbacks {
/**
* Called when an item in the navigation drawer is selected.
*/
void onHomeMenuItemSelected(int position);
}
}
public class MainActivity extends Activity implements
HomeFragment.HomeMenuCallbacks {
@Override
public void onHomeMenuItemSelected(int position) {
// Do whatever action based on which
// item from the home page menu was selected
}
}
Check this thread for discussions and link to Android dev guide: Android - I need some clarifications of fragments vs activities and views