欢迎来到天天文库
浏览记录
ID:33027094
大小:178.95 KB
页数:46页
时间:2019-02-19
《安卓实验报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Android实验报告专业:物联网工程班级:14419062学号:1441906221姓名:毛君宇2017年06月]]日实验一Activity生命周期一、实验目的Android生命周期是从程序启动到程序终止的过程。通过本次实验深入理解Android系统管理生命周期的必要性,并以Activity为例说明Android系统是如何管理程序组件的生命周期。二、实验设备1、硬件设备系统类型:Win10版本64位,处理器:Intel(R)Core(TM)i5-4210MCPU@2.60GHz2.60GHz安装内存(RAM):8.00GB2、软件设备Wi
2、n10操作系统、Androidstido>JDK、AndroidSDK、AVD三、实验内容1、实验要求观察Activity的生命周期。2、详细设计packagecom.example.android_exp_l;importandroid.os.Bundle;importandroid.support.v7.app.AppCompatActivity;importandroid.util.Log;importandroid.view.View;importandroid.widget.Button;publicclassMainActivi
3、tyextendsAppCompatActivity{privatestaticStringTAG=”LIFTCYCLE”;@Override//thewholelifecirclebeginswithcalling;protectedvoidonCreate(BundlesavedlnstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Log.i(TAG,,,(l)onCreate()M);//listeningcli
4、ckingbtn;Buttonbtn=(Button)findViewById(R.id.btn_finish);btn.setOnClickListener(newView.OnClickListener(){publicvoidonClick(Viewview){Log.i(TAG,Mfinish()n);finish();});//thewatchfullifecirclebeginswithcalling;publicvoidonStart(){super.onStart();Log.i(TAG;,(2)onStart()H);}/
5、/afteronStart()IpublicvoidonRestoreInstanceState(Bundlesavedlnstance){supe匚onRestorelnstanceState(savedlnsUmce);Log.i(TAG,"(3)onRestoreInstanceState()");I//activelifecirclecalled;publicvoidonResume(){super.onResume();Log.i(TAG,"(4)onResume()");}//afteronPause();publicvoido
6、nSaveInstanceState(BundlesavedlnstanceState){super.onSavelnstanceState(savedInstanceState);Log.i(TAG,H(5)onSaveInstanceState");}publicvoidonRestart(){super.onRestart();Log.i(TAG「(6)onRestat()");//活动牛命周期结束时调用;publicvoidonPause(){supe匚onPause();Log.i(TAG,"(7)onPause()");}//a
7、ctivelifecircleendswithcallingpublicvoidonStop(){super.onStopO;Log.i(TAG,n(8)onStopu);//thewholelifecircleendswithcallingpublicvoidonDestroyO{supe匚onDestroy();Log.i(TAG;,(9)onDetroy()M);3、结果显示05-2$ceo.vrXXcActivity2:)ccB.wrSyttea.MtJmfecYCleJktivity:oe*«>t4rt()M1f«cycl«Jkc
8、tivity:o&Start(>cea.vrSytMB.OQt05-2$cco.vrSyato.oatSytto.ootAXxf«cycXtActxvxty:ocJl«rj»OA
此文档下载收益归作者所有