Here\'s the problem. In my app, I have 5 tabs which contains activities. In each of them, I have to show differents screens. For example, the main activity of a tab is a lis
I have still a problem with this code. I don't know how to handle the android back button. I have a graphical button to going back to the last activity with the method shown above, but if I try to add this behavior on the physical back button of the device, it doesn't work. I tried with onKeyPressent with the KEY_BACK event, but it never goes in this code section.
Moreover, with this technique of subactivites, I don't have the sliding animation when I launch a new one. I try to add the animation manually, but I may not use the good technique, because it's laggy :
public void replaceContentView(String id, Intent newIntent, int flag) {
View view = mLocalActivityManager.startActivity(id, newIntent.addFlags(flag)).getDecorView();
Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_right);
view.startAnimation(animation);
this.setContentView(view);
}
Thanks
I had this same question I believe I have a pretty good answer with some code examples on this blog article I just wrote. multiple-android-acitivities
Let me know if it is helpful, or needs improvement.
Ok, the solution (given on the site above), was this :
this.m_backButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Activity1.class);
Activity1 parentActivity = (Activity1)getParent();
parentActivity.replaceContentView("activity1", intent,
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT );
}
});
and take out my main activitity from ActivityGroup. You can see the answer here : http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity#comment-4