Personal understanding of landing failure in Android learning process

Source: Internet
Author: User


Today in the process of learning, to do the function of landing failure, so we found some information, a good look at a bit, research, and slowly made!


For example: You landed on a mobile phone account, on the other side of the mobile phone also logged in the account, at this time, the previous mobile phone account will prompt login failure.

It means that there is only one account, which is not very difficult.


Every time there will be a token, each login token is not the same!


Here's a little bit of code on the front end:

In an asynchronous network request, determine whether the returned exception is a login failure:

@Overrideprotected void OnPostExecute (businessresult result) {if (Mcallback! = null &&!iscancelled ()) {if (Resul t.success) {mcallback.onsuccess (result.returnobject);} else {mcallback.onerror (result.exception); if ( Result.exception.getMessage (). Equals (Businessexception.token_invalid)) {Tokeninvalidutil.showdialog ();}}}


User Login failure Processing Tool class

public class Tokeninvalidutil {private static alertdialog salertdialog;public static void Setdialog (Alertdialog Alertdialog) {salertdialog = Alertdialog;} public static void ShowDialog () {if (Salertdialog! = null &&!salertdialog.isshowing ()) {Salertdialog.show ()}}}

Initialize in application:

Private Alertdialog createdialog () {alertdialog ad = new Alertdialog.builder (this). Setmessage (R.string.dialog_token_ invalid_message). Setpositivebutton (R.string.dialog_token_invalid_button, New Onclicklistener () {@Overridepublic void OnClick (Dialoginterface dialog, int which) {//preferenceutil.clear (); Intent Intent = new Intent (getinstance (), Loginactivity.class); Intent.setflags (Intent.flag_activity_new_task); startactivity (intent); App.getinstance (). exit ();}). Create (); Ad.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); Ad.setcanceledontouchoutside ( FALSE); ad.setcancelable (false); return AD;}


The front-end approximate code is these, the specific details do not explain!

In the app, as long as the design of a token query method, you will be prompted to login invalid!







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.