Source analysis of "Listviewjson" "Com.demo.app" "AppManager" and its role in engineering

Source: Internet
Author: User

Appmanager.java source code is as follows:

 PackageCom.demo.app;ImportJava.util.Stack;Importandroid.app.Activity;ImportAndroid.app.ActivityManager;ImportAndroid.content.Context;/*** Application Activity Management class: For activity management and application exit *@version1.0 * @created 2012-3-21*/ Public classAppManager {Private StaticStack<activity>Activitystack; Private StaticAppManager instance; PrivateAppManager () {}/*** Single Instance*/     Public StaticAppManager Getappmanager () {if(instance==NULL) {instance=NewAppManager (); }        returninstance; }    /*** Add activity to Stack*/     Public voidaddactivity (activity activity) {if(activitystack==NULL) {Activitystack=NewStack<activity>();    } activitystack.add (activity); }    /*** Gets the current activity (last pressed in the stack)*/     PublicActivity currentactivity () {Activity Activity=activitystack.lastelement (); returnactivity; }    /*** End the current activity (last pressed in the stack)*/     Public voidfinishactivity () {Activity Activity=activitystack.lastelement ();    Finishactivity (activity); }    /*** End the specified activity*/     Public voidfinishactivity (activity activity) {if(activity!=NULL) {activitystack.remove (activity);            Activity.finish (); Activity=NULL; }    }    /*** End activity for specified class name*/     Public voidFinishactivity (class<?>CLS) {         for(Activity activity:activitystack) {if(Activity.getclass (). Equals (CLS)) {finishactivity (activity); }        }    }    /*** End All activity*/     Public voidfinishallactivity () { for(inti = 0, size = activitystack.size (); i < size; i++){            if(NULL!=Activitystack.get (i))            {Activitystack.get (i). Finish ();    }} activitystack.clear (); }    /*** Exit Application*/     Public voidAppExit (Context context) {Try{finishallactivity (); Activitymanager Activitymgr=(Activitymanager) Context.getsystemservice (Context.activity_service);            Activitymgr.restartpackage (Context.getpackagename ()); System.exit (0); } Catch(Exception e) {} }}

Source analysis of "Listviewjson" "Com.demo.app" "AppManager" and its role in engineering

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.