It is concluded that dialog and alertdialog do not affect the life cycle of the activity, but affect the priority of the activity.
Core code:
in oncreated:Resources Resources= This. Getresources (); Displaymetrics Displaymetrics=Resources.getdisplaymetrics (); Final intWidthpixels = DISPLAYMETRICS.WIDTHPIXELS/2; Final intHeightpixels = DISPLAYMETRICS.HEIGHTPIXELS/2; //1//Android 5.0 Under Dialog&alertdialog does not affect the activity life cycleFloatingactionbutton fab =(Floatingactionbutton) Findviewbyid (R.id.fab); Fab.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (view view) {//snackbar.make (view, "Replace with your own action", Snackbar.length_long)//. Setaction ("Action", null). Show (); //Test Dialog//EditText EditText = new EditText (scrollingactivity.this);//Edittext.setlayoutparams (New Viewgroup.layoutparams (Widthpixels, Heightpixels));//Dialog Dialog = new Dialog (scrollingactivity.this);//Dialog.setcontentview (editText);//Dialog.settitle ("title");//Dialog.setcanceledontouchoutside (false);//dialog.show (); //Test DialogAlertdialog.builder Builder =NewAlertdialog.builder (scrollingactivity. This); Builder.settitle ("Pop-up Window"). Setmessage ("MSG"). Setnegativebutton ("Cancel",NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog.dismiss (); }}). Setpositivebutton ("Yes",NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog.dismiss (); ; }}). setcancelable (false); Builder.create (). Show (); } }); In Activity: @Overrideprotected voidOnStart () {Super. OnStart (); System.out.println ("Scrollingactivity.onstart"); } @Overrideprotected voidOnresume () {Super. Onresume (); System.out.println ("Scrollingactivity.onresume"); } @Overrideprotected voidOnPause () {Super. OnPause (); System.out.println ("Scrollingactivity.onpause"); } @Overrideprotected voidOnStop () {Super. OnStop (); System.out.println ("Scrollingactivity.onstop"); }
Interested comrades can create a new activity experience.
Android Explore 2:android 5.0 under Dialog&alertdialog does not affect the activity's life cycle