Because Flag_activity_new_task flag is used when starting ACTIVITY in (widget or service, broadcastreceiver) using the StartActivity () method, Therefore, when you exit with the Setresult tag in baseactivity, you cannot exit the application completely (only the activity that is opened by the broadcast and the activity that is opened after it is closed).
So this article is designed to use broadcast exit applications:
1. Send out of broadcast in exit event
Intent Intent = new Intent ();
Intent.setaction ("Com.android.exitapp");
Baseactivity.sendbroadcast (Intent);
2. Register the broadcast in the Baseactivity
Private Broadcastreceiver Broadcastreceiver = new Broadcastreceiver () {
@Override
public void OnReceive (context context, Intent Intent) {
TODO auto-generated Method Stub
if (Intent.getaction (). Equals ("Com.android.exitapp")) {
Finish ();
}
}
};
@Override
protected void Onresume () {
TODO auto-generated Method Stub
Super.onresume ();
Intentfilter filter = new Intentfilter ();
Filter.addaction (Systemconst.exit_app);
This.registerreceiver (this.broadcastreceiver, filter);
}
This method allows you to exit all activity.
Android uses broadcast to quit apps