欢迎来到天天文库
浏览记录
ID:14949048
大小:874.30 KB
页数:63页
时间:2018-07-31
《android实验报告》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Android实验报告实验一Activity生命周期一、实验目的Android生命周期是从程序启动到程序终止的过程。通过本次实验深入理解Android系统管理生命周期的必要性,并以Activity为例说明Android系统是如何管理程序组件的生命周期。二、实验设备1、硬件设备系统类型:Win7版本32位,处理器:Intel(R)Core(TM)i3-2350MCPU@2.30GHz2.30GHz安装内存(RAM):8.00GB2、软件设备Win7操作系统、Eclipse、JDK、AndroidSDK、ADT三、实验内容1、实验要求观察Activity的生命周期。2、详
2、细设计packagecom.example.activitylifecycle;importandroid.support.v7.app.ActionBarActivity;importandroid.os.Bundle;importandroid.util.Log;importandroid.view.Menu;importandroid.view.MenuItem;importandroid.view.View;importandroid.widget.Button;publicclassMainActivityextendsActionBarActivity{p
3、rivatestaticStringTAG="LIFECYCLE";@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Log.i(TAG,"(1)onCreate()");Buttonbutton=(Button)findViewById(R.id.button1);button.setOnClickListener(newView.OnClickListener(
4、){publicvoidonClick(Viewview){finish();}});}@OverridepublicvoidonStart(){super.onStart();Log.i(TAG,"(2)onStart()");}@OverridepublicvoidonRestoreInstanceState(BundlesavedInstanceState){super.onRestoreInstanceState(savedInstanceState);Log.i(TAG,"(3)onRestoreInstanceState()");}@Overridepub
5、licvoidonResume(){super.onResume();Log.i(TAG,"(4)onResume()");}@OverridepublicvoidonSaveInstanceState(BundlesavedInstanceState){super.onSaveInstanceState(savedInstanceState);Log.i(TAG,"(5)onSaveInstanceState()");}@OverridepublicvoidonRestart(){super.onRestart();Log.i(TAG,"(6)onRestart()
6、");}@OverridepublicvoidonPause(){super.onPause();Log.i(TAG,"(7)onPause()");}@OverridepublicvoidonStop(){super.onStop();Log.i(TAG,"(8)onStop()");}@OverridepublicvoidonDestroy(){super.onDestroy();Log.i(TAG,"(9)onDestroy()");}/*@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super
7、.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}*/@OverridepublicbooleanonCreateOptionsMenu(Menumenu){//Inflatethemenu;thisaddsitemstotheactionbarifitispresent.getMenuInflater().inflate(R.menu.main,menu);returntrue;}@OverridepublicbooleanonOptionsItemSelec
此文档下载收益归作者所有