tags:

views:

54

answers:

2

hi want to specify in code to move to specific activity after pressing back button on android key pad how i can accomplish this, frnds help me

now i got the solution with the help of our friends

hi got the solutin to my prob onBackPressed() works after 1.6 version for previous versions we need use public boolean onKeyDown(int keyCode, KeyEvent event) method

my code for this solved prob is

@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.CUR_DEVELOPMENT && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Take care of calling this method on earlier versions of // the platform where it doesn't exist. onBackPressed(); }

    return super.onKeyDown(keyCode, event);
}

//@Override
public void onBackPressed() {
    // This will be called either automatically for you on 2.0
    // or later, or by the code above on earlier versions of the
    // platform.
    Intent i=new Intent(AgesWebViewIndex.this,TabCls.class);
    i.putExtra("age", "agepage");
    startActivity(i);
    return;
}
A: 

in acitivy A -> startActivity(B);

in activity B -> startActivity(C);

in activity C -> start Activity(D);

in activity D -> go back to B or A other than C

if this is what you want... simply call finish(); after calling startActivity();


in activity A -> startActivity(B);

in activity B -> startActivity(C); finish();

in activity C -> startActivity(D); finish();

here if you press back button, you'll go directly back to activity A

hope i'm on the right track :p

optimystery
A: 

If I get your point, you may want to capture the "on-Back button clicked" event and then start your desired activity inside that.

@Override public void onBackPressed() {

// do something on back. return;

}

For more info, please take a look at: http://android-developers.blogspot.com/2009/12/back-and-other-hard-keys-three-stories.html

hungh3
thank u my frnd i hope this will solve my prob i will try this now
Ramesh Bugatha