// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/activity/StartForResultActivityTwo.java
// public class StartForResultActivityTwo extends AppCompatActivity {
//     private static final String LOG_TAG = StartForResultActivityTwo.class.getSimpleName();
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         Log.i(LOG_TAG, "onCreate(): " + savedInstanceState);
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_start_for_result_activity_two);
// 
//         ButterKnife.bind(this);
//     }
// 
// 
//     @OnClick(R.id.set_result_ok)
//     void onOkClick() {
//         setResult(RESULT_OK);
//         finish();
//     }
// 
//     @OnClick(R.id.set_result_cancel)
//     void onCancelClick() {
//         setResult(RESULT_CANCELED);
//         finish();
//     }
// 
// 
//     @Override
//     protected void onRestart() {
//         Log.i(LOG_TAG, "onRestart()");
//         super.onRestart();
//     }
// 
//     @Override
//     protected void onStart() {
//         Log.i(LOG_TAG, "onStart()");
//         super.onStart();
//     }
// 
//     @Override
//     public void onStateNotSaved() {
//         super.onStateNotSaved();
//         Log.d(LOG_TAG, "onStateNotSaved");
//     }
// 
//     @Override
//     protected void onRestoreInstanceState(Bundle savedInstanceState) {
//         Log.d(LOG_TAG, "onRestoreInstanceState(): " + savedInstanceState);
//         super.onRestoreInstanceState(savedInstanceState);
//     }
// 
//     @Override
//     protected void onResume() {
//         Log.i(LOG_TAG, "onResume()");
//         super.onResume();
//     }
// 
//     @Override
//     protected void onPause() {
//         Log.i(LOG_TAG, "onPause()");
//         super.onPause();
//     }
// 
//     @Override
//     protected void onSaveInstanceState(Bundle outState) {
//         super.onSaveInstanceState(outState);
//         Log.d(LOG_TAG, "onSaveInstanceState(): " + outState);
//     }
// 
//     @Override
//     protected void onStop() {
//         Log.i(LOG_TAG, "onStop()");
//         super.onStop();
//     }
// 
//     @Override
//     protected void onDestroy() {
//         Log.i(LOG_TAG, "onDestroy()");
//         super.onDestroy();
//     }
// }


import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.activity.StartForResultActivityTwo;
import butterknife.ButterKnife;
import butterknife.OnClick;
        return inflater.inflate(R.layout.fragment_g, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        Log.i(LOG_TAG, "onViewCreated()");
        super.onViewCreated(view, savedInstanceState);
        ButterKnife.bind(this, view);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        Log.i(LOG_TAG, "onActivityCreated()");
        super.onActivityCreated(savedInstanceState);

    }


    @OnClick(R.id.add_child_fragment)
    void addChildFragment() {
        Fragment fragmentByTag = getChildFragmentManager().findFragmentByTag(FragmentG.TAG);
        if (fragmentByTag == null) {
            getChildFragmentManager().beginTransaction()
                    .add(R.id.container, FragmentG.createInstance("child", 34), FragmentG.TAG).commit();
        }
    }

    @OnClick(R.id.start_activity_for_result)
    void turnToAnotherActivity() {

// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/activity/StartForResultActivityTwo.java
// public class StartForResultActivityTwo extends AppCompatActivity {
//     private static final String LOG_TAG = StartForResultActivityTwo.class.getSimpleName();
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         Log.i(LOG_TAG, "onCreate(): " + savedInstanceState);
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_start_for_result_activity_two);
// 
//         ButterKnife.bind(this);
//     }
// 
// 
//     @OnClick(R.id.set_result_ok)
//     void onOkClick() {
//         setResult(RESULT_OK);
//         finish();
//     }
// 
//     @OnClick(R.id.set_result_cancel)
//     void onCancelClick() {
//         setResult(RESULT_CANCELED);
//         finish();
//     }
// 
// 
//     @Override
//     protected void onRestart() {
//         Log.i(LOG_TAG, "onRestart()");
//         super.onRestart();
//     }
// 
//     @Override
//     protected void onStart() {
//         Log.i(LOG_TAG, "onStart()");
//         super.onStart();
//     }
// 
//     @Override
//     public void onStateNotSaved() {
//         super.onStateNotSaved();
//         Log.d(LOG_TAG, "onStateNotSaved");
//     }
// 
//     @Override
//     protected void onRestoreInstanceState(Bundle savedInstanceState) {
//         Log.d(LOG_TAG, "onRestoreInstanceState(): " + savedInstanceState);
//         super.onRestoreInstanceState(savedInstanceState);
//     }
// 
//     @Override
//     protected void onResume() {
//         Log.i(LOG_TAG, "onResume()");
//         super.onResume();
//     }
// 
//     @Override
//     protected void onPause() {
//         Log.i(LOG_TAG, "onPause()");
//         super.onPause();
//     }
// 
//     @Override
//     protected void onSaveInstanceState(Bundle outState) {
//         super.onSaveInstanceState(outState);
//         Log.d(LOG_TAG, "onSaveInstanceState(): " + outState);
//     }
// 
//     @Override
//     protected void onStop() {
//         Log.i(LOG_TAG, "onStop()");
//         super.onStop();
//     }
// 
//     @Override
//     protected void onDestroy() {
//         Log.i(LOG_TAG, "onDestroy()");
//         super.onDestroy();
//     }
// }


// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/fragment/FragmentG.java
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.activity.StartForResultActivityTwo;
import butterknife.ButterKnife;
import butterknife.OnClick;

        return inflater.inflate(R.layout.fragment_g, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        Log.i(LOG_TAG, "onViewCreated()");
        super.onViewCreated(view, savedInstanceState);
        ButterKnife.bind(this, view);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        Log.i(LOG_TAG, "onActivityCreated()");
        super.onActivityCreated(savedInstanceState);

    }


    @OnClick(R.id.add_child_fragment)
    void addChildFragment() {
        Fragment fragmentByTag = getChildFragmentManager().findFragmentByTag(FragmentG.TAG);
        if (fragmentByTag == null) {
            getChildFragmentManager().beginTransaction()
                    .add(R.id.container, FragmentG.createInstance("child", 34), FragmentG.TAG).commit();
        }
    }

    @OnClick(R.id.start_activity_for_result)
    void turnToAnotherActivity() {

        startActivityForResult(new Intent(getActivity(), StartForResultActivityTwo.class), requestCode);