利用Android的Log 演示一个activity的生命周期代码
代码:
//DemoActivity.java
package uni.activity;
/*
@author octobershiner
2011 7 22
SE.HIT
*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class ActivityDemoActivity extends Activity {
/** Called when the activity is first created. */
private static final String TAG = "demo";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("demo", "this is a test string ");
}
protected void onStart(){
super.onStart();
Log.i(TAG, "The activity state---->onStart");
}
protected void onRestart(){
super.onRestart();
Log.i(TAG, "The activity state---->onReatart");
}
protected void onResume(){
super.onResume();
Log.i(TAG, "The activity state---->onResume");
}
protected void onPause(){
super.onPause();
Log.i(TAG, "The activity state---->onPause");
}
protected void onStop(){
super.onStop();
Log.i(TAG, "The activity state---->onStop");
}
protected void onDestroy(){
super.onDestroy();
Log.i(TAG, "The activity state---->onDestroy");
}
}
代码:
//DemoActivity.java
package uni.activity;
/*
@author octobershiner
2011 7 22
SE.HIT
*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class ActivityDemoActivity extends Activity {
/** Called when the activity is first created. */
private static final String TAG = "demo";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("demo", "this is a test string ");
}
protected void onStart(){
super.onStart();
Log.i(TAG, "The activity state---->onStart&quo
- 发表评论
-
- 最新评论 更多>>