Public class mainactivity extends activity {Private Static final string tag = "mainactivity"; @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_main); If (savedinstancestate! = NULL) {log. E (TAG, "oncreate | Reade page ----" + savedinstancestate. getstring ("page");} system. out. println ("11111") ;}@ override public Boolean oncreateoptionsmenu (menu) {getmenuinflater (). inflate (R. menu. activity_main, menu); Return true;}/*** this method is called only when the acitivity is recycled by the system, this is an opportunity for users to save data. Of course, you can also not save it. * if you think that you press the back key to destroy the current acitivity, The onsaveinstancestate method will not be executed. ** about this possibility: * 1 Press the power key * 2 to jump to another activity * 3 press home or long press home to select another application * 4 to switch between portrait screens **. However, we do not save the data in this method because it is stopped from setting. application this method will not be executed * generally saves data in the onstop method of the life cycle */@ override protected void onsaveinstancestate (bundle outstate) {// todo auto-generated method stub log. E (TAG, "onsaveinstancestate run .. "); outstate. putcharsequence ("page", "page 8"); super. onsaveinstancestate (outstate);}/*** onrestoreinstancestate is called only when the activity is indeed recycled by the system, for example, switching the onrestoreinstancestate on the horizontal and vertical screens will be executed * generally press the Home Key to return to the activity. acitivity is generally not destroyed by the system, and onrestoreinstancestate will not be called * onrestoreinstancestate) the parameter is also passed to oncreate (bundle savedinstancestate) **/@ override protected void onrestoreinstancestate (bundle savedinstancestate) {// todo auto-generated method stub log. E (TAG, "onrestoreinstancestate run .. "); log. E (TAG, "onrestoreinstancestate | Reade page ----" + savedinstancestate. getstring ("page"); super. onrestoreinstancestate (savedinstancestate );}}
05-04 12:39:24. 129: E/mainactivity (13121): onsaveinstancestate run ..
05-04 12:39:24. 539: E/mainactivity (13121): oncreate | Reade page ---- page 8
05-04 12:39:24. 539: E/mainactivity (13121): onrestoreinstancestate run ..
05-04 12:39:24. 539: E/mainactivity (13121): onrestoreinstancestate | Reade page ---- page 8
05-04 12:40:22. 919: E/mainactivity (13121): onsaveinstancestate run ..
05-04 12:40:28. 379: E/mainactivity (13121): oncreate | Reade page ---- page 8
05-04 12:40:28. 379: E/mainactivity (13121): onrestoreinstancestate run ..
05-04 12:40:28. 379: E/mainactivity (13121): onrestoreinstancestate | Reade page ---- page 8
05-04 12:39:24. 129: E/mainactivity (13121): onsaveinstancestate run ..
05-04 12:39:24. 539: E/mainactivity (13121): oncreate | Reade page ---- page 8
05-04 12:39:24. 539: E/mainactivity (13121): onrestoreinstancestate run ..
05-04 12:39:24. 539: E/mainactivity (13121): onrestoreinstancestate | Reade page ---- page 8
05-04 12:40:22. 919: E/mainactivity (13121): onsaveinstancestate run ..
05-04 12:40:28. 379: E/mainactivity (13121): oncreate | Reade page ---- page 8
05-04 12:40:28. 379: E/mainactivity (13121): onrestoreinstancestate run ..
05-04 12:40:28. 379: E/mainactivity (13121): onrestoreinstancestate | Reade page ---- page 8