0

we used back key by calling

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        moveTaskToBack(true);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

but,we used 4 classes in our application.if we gives back button,its working well and returning to application home page.but wen we go next time its in same class.(we used above back key coding in 3 rd class,its remains same page).

is there any alternative method.if anybody knows pls reply.

Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103

3 Answers3

0

use this...

onBackPressed not close Current Activity In Android

Community
  • 1
  • 1
Mehul Ranpara
  • 4,245
  • 2
  • 26
  • 39
0

Try overriding onBackPressed()

Adinia
  • 3,722
  • 5
  • 40
  • 58
sat
  • 40,138
  • 28
  • 93
  • 102
0

moveTaskToBack() only moves the Activity to the back of the activity stack, it doesn't actually close the Activity. What you want is finish(), which will close the Activity and Android will automatically take you back to the previous Activity in the stack.

For more information, see the documentation: http://developer.android.com/guide/topics/fundamentals.html#acttask

Rowno
  • 3,325
  • 2
  • 23
  • 14