Press back button to another activity
<p>I try below code to call another activity while press back button:</p>

<pre><code>@Override
public boolean onKeyUp(int keyCode, KeyEvent msg) {
switch(keyCode) {
case(KeyEvent.KEYCODE_BACK):
Intent intent = new Intent(AActivity.this, BActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
Window w = NASGroup.group.getLocalActivityManager().startActivity("BActivity", intent);  
View view = w.getDecorView();  
MyGroup.group.setContentView(view);  
return true; 
}
return false;
}
</code></pre>

<p>But while press back button, it get out of the app.
I see the logcat, it does not run the function onKeyUp, and also without any message.
The same code in onKeyUp I try to below code to a button in layout, it works.</p>

<pre><code>cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(AActivity.this, BActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
Window w = NASGroup.group.getLocalActivityManager().startActivity("BActivity", intent);  
View view = w.getDecorView();  
MyGroup.group.setContentView(view);  
}
});
</code></pre>

<p>How can I modify it?</p>
