Code example for FragmentActivity

Methods: getApplicationContext, getIntent, getSupportFragmentManager, onCreate

0
	private ArrayList<PhotoWrapper> photos;
	private String artTitle;
 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		Utils.setTheme(this);
		Utils.enableDump(this);
 
		ServiceFactory.init(getApplicationContext()); 
 
		setupState(savedInstanceState);
	} 
 
	@Override 
	protected void onPause() { 
		super.onPause(); 
		//FIXME OutOfMemoryExceptions 
		System.gc();
	} 
 
	@SuppressWarnings("unchecked") 
	private void setupState(Bundle savedInstanceState) {
		if (savedInstanceState != null) return;
 
		Intent intent = getIntent();
		if (intent.hasExtra(EXTRA_WRAPPERS)) {
			photos = (ArrayList<PhotoWrapper>) intent.getExtras().getSerializable(EXTRA_WRAPPERS);
		} 
		if (intent.hasExtra(EXTRA_TITLE)) {
			artTitle = intent.getExtras().getString(EXTRA_TITLE);
		} 
 
		getSupportFragmentManager() 
				.beginTransaction() 
				.replace(android.R.id.content,
						new GalleryFragment(photos, artTitle, intent.getExtras().getBoolean(EXTRA_IS_EDIT_MODE, false)))
				.commit(); 
	}