Back to project page android-component-location.
The source code is released under:
MIT License
If you think the Android project android-component-location listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.yingchn.android.activity; // w ww .j av a 2 s . c om import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarActivity; import android.view.MenuItem; import com.yingchn.android.location.R; public class ArbitraryFragmentActivity extends ActionBarActivity{ public static final String INTENT_PARAMS_BUNDLE = "intent_params_bundle"; public static final String INTENT_PARAMS_FRAGMENT_NAME = "intent_params_fragment_name"; @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.activity_arbitrary); Fragment fragment; try { fragment = (Fragment)Class.forName(getIntent().getExtras().getString(INTENT_PARAMS_FRAGMENT_NAME)).newInstance(); fragment.setArguments(getIntent().getExtras().getBundle(INTENT_PARAMS_BUNDLE)); getSupportFragmentManager() .beginTransaction() .replace(R.id.layout_fragment_container, fragment) .commit(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (Exception e){ e.printStackTrace(); } } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId() == android.R.id.home) this.finish(); return super.onOptionsItemSelected(item); } }