I'm developing an app which contain TabHost
,in one of those tabs i have an ActivityGroup
, and from this ActivityGroup
, i launch another SubActivity
( let's say that i Launch an Activity
A ), and until this , everything is OK.
The problem is when i press the BackButton ,the CurrentActivity( Activity
A ) is destroyed, but the ParentActivity( The ActivityGroup
) is not resumed , and the app show just a null Window with the Title of My App ( "My Application Title" ) .
The Code to launch the Activity
A from my ActivityGroup
is :
View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView();
this.setContentView(view);
and i have overrided
the method onKeyDown
like this in my ActivityGroup
:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.i(TAG, "onKeyDown");
if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
Activity current = getLocalActivityManager().getCurrentActivity();
Log.i(TAG, current.getIntent().getStringExtra("id"));
current.finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
but it seems that the method onKeyDown
is never called because a i didn't get the Log "onKeyDown" displayed.
and the logcat display just this :
01-05 11:04:38.012: W/KeyCharacterMap(401): No keyboard for id 0
01-05 11:04:38.012: W/KeyCharacterMap(401): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
what i want is to display the ActivityGroup
when my Activity
A is Destroyed.
NB : my app level is 4 : *Android 1.6* , so i can't override
the method onBackPressed()
Thank you all for your help
-----------------------------------EDIT ----------------------------------------
I have added the code of my onKeyDown
like this on my Activity
A :
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
ParentActivity parentActivity = (ParentActivity) this.getParent();
parentActivity.onKeyDown(keyCode, event);
return true;
}
return super.onKeyDown(keyCode, event);
}
And in my ParentActivity
, i have :
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
Log.i(TAG, "onKeyDown");
int len = idOfSubActivities.size();
String idOfCurrentActivity = idOfSubActivities.get(len-1);
Activity currentActivity = getLocalActivityManager().getActivity(idOfCurrentActivity);
currentActivity.finish();
idOfSubActivities.remove(len - 1);
return true;
}
return super.onKeyDown(keyCode, event);
}
I got the same result , the Activity
A is stopped , but it still give me the null window with the title of my app , and it doesn't display my ActivityGroup
(ParentActivity
)