tabHostを使用するアプリケーションを開発しています。その5つのタブでは、すべてのタブで複数のアクティビティを開くことができます。私の問題は、最後のタブ(5番目のタブ)でカメラキャプチャの機能を実行したため、カメラを開いて画像をキャプチャしましたが、onActivityResultを呼び出す前に、最初のタブ(1番目のタブ)を呼び出し、その後、最後のタブのonActivityResultを呼び出します。しかし、なぜこれが起こるのか分かりませんか?
私のコードはここにあります:
複数のアクティビティを作成するには、これを使用します:http: //ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html
TabPage:
public class TabPage extends TabActivity {
Resources res;
public static TabHost tabHost;
TabSpec obj, obj1;
Intent intent;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tabHost = getTabHost();
res = getResources();
obj1 = tabHost.newTabSpec("tab1");
tabHost.addTab(obj1.setIndicator("",
res.getDrawable(R.drawable.tab1)).setContent(
new Intent(this, Act1.class)));
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
obj = tabHost.newTabSpec("tab2");
tabHost.addTab(obj.setIndicator("",
res.getDrawable(R.drawable.tab2)).setContent(
new Intent(this, Act2.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
obj = tabHost.newTabSpec("tab3");
tabHost.addTab(obj.setIndicator("",
res.getDrawable(R.drawable.tab3)).setContent(
new Intent(this, Act3.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
obj = tabHost.newTabSpec("tab4");
tabHost.addTab(obj.setIndicator("",
res.getDrawable(R.drawable.tab4)).setContent(
new Intent(this, Act4.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
obj = tabHost.newTabSpec("tab5");
tabHost.addTab(obj.setIndicator("",
res.getDrawable(R.drawable.tab5)).setContent(
new Intent(this, Act5.class)));
tabHost.setCurrentTab(0);
}
public void switchTab(int tab) {
tabHost.setCurrentTab(tab);
}
}