-3

When user back press on the login screen of my application application crashes. I use below code to launch my login activity -

private void showLoginActivity() {
    Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    finish();
}

I do some background operation in this screen through asynctask. I saw the logcat It's showing problem in asynctask as the login activity finishes and the task is still running. How can I resolve this problem ?

Thanks in advance

unflagged.destination
  • 1,576
  • 3
  • 19
  • 38

3 Answers3

0

if how try this please:

Intent i = new Intent(getApplicationContext(), LoginActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);
deepak825
  • 432
  • 2
  • 8
0

Got the solution. I used some flags to launch login activity. Below are those flags which I used -

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
unflagged.destination
  • 1,576
  • 3
  • 19
  • 38
  • 1
    of course **it is not a solution** ... it is rather dirt fix ... share logcat's log with us - there should be a real solution .... – Selvin Mar 18 '15 at 11:41
0

I think there is a problem in your flags. Probably in your

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

i would suggest you this to read and understand.

Community
  • 1
  • 1
ghost talker
  • 402
  • 5
  • 15