package com.jinbei.appclient.view.history; /** * @author DuoShou * @Created at 2018/3/23 11:30 */ import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.Button; public class Activity01 extends Activity{ private static final String TAG = "demo"; private Button button_B; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); // setContentView(R.layout.activity01); // button_B = (Button)this.findViewById(R.id.Button_B); // button_B.setOnClickListener(new myButtonListener()); Log.d(TAG, "The activity01 state---->onCreate"); } // private class myButtonListener implements View.OnClickListener { // @Override // public void onClick(View v) { // TextView tx = (TextView) findViewById(R.id.tx1); // tx.setTextColor(Color.BLUE); // } // }; protected void onStart(){ super.onStart(); Log.d(TAG, "The activity01 state---->onStart"); } protected void onRestart(){ super.onRestart(); Log.d(TAG, "The activity01 state---->onReatart"); } protected void onResume(){ super.onResume(); Log.d(TAG, "The activity01 state---->onResume"); } protected void onPause(){ super.onPause(); Log.d(TAG, "The activity01 state---->onPause"); //调用isFinishing方法,判断activity是否要销毁 if(isFinishing()){ Log.w(TAG, "The activity01 will be destroyed!"); }else{ Log.w(TAG, "The activity01 is just pausing!"); } } protected void onStop(){ super.onStop(); Log.d(TAG, "The activity01 state---->onStop"); } protected void onDestroy(){ super.onDestroy(); Log.d(TAG, "The activity01 state---->onDestroy"); } }
package com.jinbei.appclient.view.history; /** * @author DuoShou * @Created at 2018/3/23 11:29 */ import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.Button; public class ActivityDemoActivity extends Activity { /** Called when the activity is first created. */ private static final String TAG = "demo"; private Button button_A; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Log.i(TAG, "The activityDemo state---->onCreate"); // setContentView(R.layout.main); // button_A = (Button)this.findViewById(R.id.Button_A); // button_A.setOnClickListener(new myButtonListener()); } // private class myButtonListener implements OnClickListener{ // @Override // public void onClick(View v) { // // TODO Auto-generated method stub // Intent intent = new Intent(); // intent.setClass(ActivityDemoActivity.this, Activity01.class); // ActivityDemoActivity.this.startActivity(intent); // //感兴趣的朋友可以取消下面的代码注释,来测试finish方法的使用,会发现第一个activity会被强制终止 // //ActivityDemoActivity.this.finish(); // } // }; protected void onStart(){ super.onStart(); Log.i(TAG, "The activityDemo state---->onStart"); } protected void onRestart(){ super.onRestart(); Log.i(TAG, "The activityDemo state---->onReatart"); } protected void onResume(){ super.onResume(); Log.i(TAG, "The activityDemo state---->onResume"); } protected void onPause(){ super.onPause(); //调用isFinishing方法,判断activity是否要销毁 Log.i(TAG, "The activityDemo state---->onPause"); if(isFinishing()){ Log.w(TAG, "The activityDemo will be destroyed!"); }else{ Log.w(TAG, "The activityDemo is just pausing!"); } } protected void onStop(){ super.onStop(); Log.i(TAG, "The activityDemo state---->onStop"); } protected void onDestroy(){ super.onDestroy(); Log.i(TAG, "The activityDemo state---->onDestroy"); } }