Code example for FragmentActivity

Methods: finish, getActionBar, getApplicationContext, getIntent, onCreate, startActivity

0
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		// Must do this before super.onCreate 
		ActivityHelper.readAndSetSettings(this);
		super.onCreate(savedInstanceState);
 
		final ActionBar actionBar = getActionBar();
		actionBar.setDisplayShowTitleEnabled(true);
		actionBar.setDisplayHomeAsUpEnabled(true);
 
		handleIntent(getIntent()); 
	} 
	 
	/** 
	 * To allow child classes to override content 
	 */ 
	protected Fragment getFragment() {
		return FragmentSearch.getInstance(mQuery);
	} 
 
	@AfterViews 
	void loadContent() { 
		getSupportFragmentManager() 
				.beginTransaction() 
				.add(R.id.fragmentPlaceHolder, 
						getFragment()).commit(); 
	} 
 
	@Override 
	protected void onNewIntent(Intent intent) {
		setIntent(intent);
		handleIntent(intent);
	} 
 
	void handleIntent(Intent intent) {
		if (intent == null) return;
 
		if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
			mQuery = intent.getStringExtra(SearchManager.QUERY);
		} 
		else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
			intent.setClass(getApplicationContext(), ActivityMain_.class);
			startActivity(intent);
			finish(); 
		} 
	} 
 
	@Override 
	public boolean onOptionsItemSelected(MenuItem item) {