Android Open Source - android-component-location Arbitrary Fragment Activity






From Project

Back to project page android-component-location.

License

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.

Java Source Code

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);
    }
}




Java Source Code List

android.support.v4.preference.PreferenceFragment.java
android.support.v4.preference.PreferenceManagerCompat.java
com.sothree.slidinguppanel.SlidingUpPanelLayout.java
com.yingchn.android.AppContext.java
com.yingchn.android.MyApplication.java
com.yingchn.android.activity.ArbitraryFragmentActivity.java
com.yingchn.android.activity.MainActivity.java
com.yingchn.android.activity.WLocation.java
com.yingchn.android.fragment.LogFragment.java
com.yingchn.android.fragment.SettingFragment.java
com.yingchn.android.location.MyLocationManager.java
com.yingchn.android.util.FragmentUtil.java