Android Better activity life-cycle callback

Source: Internet
Author: User

/** * This class allows your listen to when the user is entering the background (i.e. after a home button press, * or op Ening recent apps etc) and when the user resumes the application from the background. * * @author John McDonnell */public class Betteractivitylifecyclecallbacks implements    application.activitylifecyclecallbacks {private int mforegroundactivities;    Private Boolean mhasseenfirstactivity;     Private Boolean mchangingconfiguration; @Override public void onactivitycreated (activity activity, Bundle savedinstancestate) {} @Override public void on         Activitystarted (activity activity) {mforegroundactivities++; if (mhasseenfirstactivity && mforegroundactivities = = 1 &&!mchangingconfiguration) {Applicati        Ondidenterforeground (activity);        } mhasseenfirstactivity = true;    Mchangingconfiguration = false; } @Override public void onactivityresumed (activity activity) {} @Override Public void onactivitypaused (activity activity) {} @Override public void onactivitystopped (activity activity) {         mforegroundactivities--;        if (mforegroundactivities = = 0) {applicationdidenterbackground (activity);    } mchangingconfiguration = Activity.ischangingconfigurations (); } @Override public void onactivitysaveinstancestate (activity activity, Bundle outstate) {} @Override public V OID onactivitydestroyed (activity activity) {}/** * One day we'll be as cool as IOS */protected void Applicationdidenterforeground (Activity topactivity) {} protected void Applicationdidenterbackground (activity last Activity) {}}

  

Android Better activity life-cycle callback

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.