<span id="Label3"></p><p><p>Android App if it is related to the account, generally do not allow an account on more than one device to log on at the same time, when this happens, the page will be redirected to the login page requires the user to log in Again. Here's How to apply a fallback stack when this happens:</p></p><p><p>Here are a few things that can happen:</p></p><p><p>1. Users Re-login using the account you just made:</p></p><p><p>In the start of the homeactivity, as long as the addition of Intent.flag_activity_clear_top logo can be homeactivity above the ACTIVITY pops, so that homeactivity become the top of the Stack.</p></p><p><p>2. User Login with another account:</p></p><p><p>In the above approach, <span style="color: #ff0000;">also make sure that the homeactivity regain the screen focus, display the current User's information, not the information of the previous user <span style="color: #000000;">(the simple implementation is to put the loading page work in the Onresume () METHOD)</span></span>.</p></p><p><p>3. When the user exits directly by clicking the back button:</p></p><p><p>You can call Android.os.Process directly. <span style="font-style: italic;">killprocess (android.os.Process. <span style="font-style: italic;"> Mypid ()); </span></span> simply and rudely end the current process.</p></p><p><p>The above is for a few simple cases, the actual work of the situation encountered more complex than This. The work of homeactivity often contains a viewpager,viewpager and corresponds to a plurality of fragment. <span style="color: #ff0000;">in this context, the second scenario is a disaster (each fragment is restored to the current User's state)! <span style="color: #000000;">below are the homeactivity in my current project. Below is a tab bar, with each label corresponding to a Fragment. </span></span></p></p><p><p><span style="color: #ff0000;"><span style="color: #000000;"></span></span></p></p><p><p>If you follow the previous method, you are honestly maintaining the state of each fragment so that they remain in sync with the current user. But the logic is too complicated, to consider all the circumstances of the written code will not be able to read it!</p></p><p><p>Continue to return to our problem, in fact, the essence of the problem is non-stack top activity maintenance issues. If we jump to the landing page, there is no activity at the bottom of the stack, so it is the same as the initial login, all the problems are not solved?</p></p><p><p>Here's my Idea:</p></p><p><p>Maintain a list of activity in application, add yourself to the list when the activity is created, and remove yourself from the list when it is Destroyed. If activity is just back in the background,</p></p><p><p></p></p><p><p>Android Processing user forced offline</p></p></span>
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