Activity生命周期

Activity生命周期

Oncreate:第一次创建时

Onstartactivity可见时

Onresumeactivity获取焦点时

Onpause:启动其他activity

Onstopactivity不可见时

Onrestart:已经创建过,再次可见

Ondestory:销毁,调用finish时或系统资源紧张被kill

 

 

一:firistActivity启动secondactivity,并且secondactivityfiristActivity完全遮住

firistActivity.Oncreate

firistActivity.Onstart

firistActivity.Onresume

--启动secondactivity,并且secondactivityfiristActivity完全遮住

firistActivity.Onpause

secondactivity.Oncreate

secondactivity.Onstart

secondactivity.Onresume

firistActivity.onstop

--按返回,重新回到firistActivity

Secondactivity.Onpause

firistActivity.Onrestart

firistActivity.Onstart

firistActivity.Onresume

Secondactivity.onstop

 

二:firistActivity启动secondactivity,并且secondactivity是对话框风格activity

firistActivity.Oncreate

firistActivity.Onstart

firistActivity.Onresume

--启动secondactivity,并且secondactivity是对话框风格activity

firistActivity.Onpause

secondactivity.Oncreate

secondactivity.Onstart

secondactivity.Onresume

--按返回,重新回到firistActivity

Secondactivity.Onpause

firistActivity.Onresume

Secondactivity.onstop

你可能感兴趣的:(android)