Android off App Program

Source: Internet
Author: User

There are about 4 ways to close the Android program:

The first type:

CurrentVersion = Android.os.Build.VERSION. (CurrentVersion > Android.os.Build.VERSION_CODES.) {Intent Startmain = Intent (Intent.) Startmain.addcategory (Intent.) Startmain.setflags (Intent.) StartActivity (Startmain) System. ()} {Activitymanager am = (activitymanager) getsystemservice () Am.restartpackage (Getpackagename ())}

This way of shutting down is what I'm using now, and it feels good to be. And it's all about the program and it's all closed down.

The second type:

             for (Activity activity:activities) { 
       & nbsp;        activity.finish (); 
            } 
             OnDestroy (); 
            system.exit (0);  
  This needs to put all the interfaces in a collection, and when the collection has the same activity there will be problems (of course, this problem can be resolved)

  Third: android.os.process.killprocess (Android.os.Process.myPid ())    //Get pid 
                  system.exit (0);  //Standard exit method for general Java, C #, A return value of 0 indicates normal exit

I don't know how to use it.

The fourth type:

The first step is to show that the method runs on Android 1.5 API level 3 to be able, while requiring permissions

              activitymanager am = ( Activitymanager) Getsystemservice (Context.activity_service);
              am.restartpackage ( Getpackagename ());  
               system will , the package under, all processes, services, all killed, you can kill clean, to pay attention to add  
               <uses-permission android:name=\ "android.permission.restart_packages\" ></uses-permi ssion

I don't know how to use it.



Android off App Program

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.