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!