Android Program Exit method

Source: Internet
Author: User

App Exit method Record:

1.exit

System.exit (0);

If the parameter is 0, the exit is normal, and a non-0 is the exception ending program.

If you use the first activity, close the app, or return to the first activity effect.

This method only shuts down the activity and does not shut down the service.


2.Pid

int pid = Android.os.Process.myPid ();//Get PIDandroid.os.Process.killProcess (PID) of current application;//Kill current Process

When this method exits the application, some post-processes are retained, for example: Service,notifications.


3.PackageName

Get Application Manager Activitymanager Manager = (Activitymanager) context.getsystemservice (context.activity_serv ICE);//force the end of the current application manager.killbackgroundprocesses (Context.getpackagename ());

exiting the app this way ends all activity in the application, because this method kills all processes, including activity,service,notifications, based on the application's package name.



This article is from the "Remember" blog, be sure to keep this source http://ziruo.blog.51cto.com/10107518/1838625

Android Program Exit method

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.