0

I create a Expense Manager app. I was write below code for exit But it work for below api 21 need help for exit code API level 21

public class Logout extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

     if(android.os.Build.VERSION.SDK_INT >= 21)
        {
          ***//Code for API level 21 and Above***
        }
        else
        {
            finish();
        }
}
public static void exitApplication(Context context)
{
    Intent intent = new Intent(context, Logout.class);

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    context.startActivity(intent);
}
}
Anand Singh
  • 5,672
  • 2
  • 23
  • 33
Prashant Gosai
  • 1,186
  • 1
  • 10
  • 18

1 Answers1

0

You could run the below code to exit out of the application

getActivity().finish();
System.exit(0);
Domain
  • 11,562
  • 3
  • 23
  • 44
  • [_Don't do this._](http://stackoverflow.com/questions/16480867/system-exit0-doesnt-close-all-my-activities) – nhaarman Aug 07 '15 at 12:08