[ANDROID] Callback when the app loading interface is finished, onwindowfocuschanged use

Source: Internet
Author: User

 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.