1, such as login. If the following method is outside the call, then how to execute the login operation in Loginactivity, after the successful callback listener interface? If it is a normal class, you can pass the listener class object through the constructor function. However, it is not possible to pass listeners in activity, so consider using broadcast.
Public voidLoginFinalLoginonclicklistener Listener) {Intent Intent=NewIntent (context, loginactivity.class); Intent.setflags (Intent.flag_activity_new_task); Broadcastreceiver Mreceiver=NewBroadcastreceiver () { Public voidOnReceive (Context context, Intent Intent) {Listener.handlelogin (true, "receiver. Broadcastreceiver. "); } }; Intentfilter Intentfilter=NewIntentfilter ("Android.intent.action.MAIN"); Context.registerreceiver (Mreceiver, Intentfilter); Context.startactivity (intent);}
2. After successful login in the Loginactivity class, send a broadcast notification to log in successfully.
New Intent ("Android.intent.action.MAIN"); Sendbroadcast (intent);
Reference: http://buddie.iteye.com/blog/977352