PackageCom.example.test_resume;Importandroid.app.Activity;ImportAndroid.os.Bundle;/*** In onwindowfocuschanged operation can effectively avoid the first launch of the app and every time from the background after the loading pop-up window times wrong unable to add window *--token null is not valid BUG * * * @authorNULL **/ Public classMainactivityextendsActivity {Private BooleanIsfirstlaunch =false; Private BooleanIsresume =false; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Isfirstlaunch=true; } @Overrideprotected voidOnresume () {Super. Onresume (); Isresume=true; } @Override Public voidOnwindowfocuschanged (BooleanHasfocus) { Super. onwindowfocuschanged (Hasfocus); if(hasfocus) {if(isfirstlaunch) {Isfirstlaunch=false; //TODO The first start interface after loading the operation } if(isresume) {Isresume=false; //TODO every time the interface has finished loading after it has been opened from the background } } } /*** To remove the action to add window to the background*/@Overrideprotected voidOnPause () {Super. OnPause (); }}
[ANDROID] Callback when the app loading interface is finished, onwindowfocuschanged use