How Android implements the Logout function

Source: Internet
Author: User

1. First of all, what do you know about the simple logout process?

A. For example, just like the apps we use often, such as QQ. When we click the Logout button, we will return to the login interface again, it is useless to press the return key again.

B. On Android to achieve this function, first you need to understand the meaning of taskstack. If you get it. Please proceed to step c below.

C. Let's start by simulating the interface. There is a button, click this button we have realized the function of logout.


2. The next step is how you can implement your logout process, the final point of this process is that you have to clearly understand that when you log off, you are actually emptying your taskstack, as long as you do this. The logout function is complete. To set intent flag here, the taskstack will be emptied when the activity jump is completed and a new taskstack will be created.

                     Intent logoutintent = new Intent (CTX, Loginactivity.class);
                     Logoutintent.setflags (Intent.flag_activity_clear_task | Intent.flag_activity_new_task);
                    startactivity ( logoutintent);

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.