问题描述
我正在开发一个使用tabHost的应用程序。在这5个选项卡,每个和每一个标签可以同时打开多个活动。我的问题是,在最后一个选项卡(5片)我没有摄像头采集的功能,所以它打开摄像头和捕捉图像,但通话onActivityResult它调用第一个选项卡(第1片)和最后一个选项卡的这一呼吁onActivityResult前后。但我不知道为什么会这样?
我的code是在这里:
有关创建多个活动,我用这样的:的
TabPage的:
公共类TabPage的扩展TabActivity {
资源资源;
公共静态TabHost tabHost;
则tabspec OBJ,OBJ1;
意向意图;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
tabHost = getTabHost();
RES = getResources();
OBJ1 = tabHost.newTabSpec(TAB1);
tabHost.addTab(obj1.setIndicator(,
res.getDrawable(R.drawable.tab1))。setContent(
新的意图(这一点,Act1.class)));
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
物镜= tabHost.newTabSpec(TAB2);
tabHost.addTab(obj.setIndicator(,
res.getDrawable(R.drawable.tab2))。setContent(
新的意图(这一点,Act2.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
物镜= tabHost.newTabSpec(TAB3);
tabHost.addTab(obj.setIndicator(,
res.getDrawable(R.drawable.tab3))。setContent(
新的意图(这一点,Act3.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
物镜= tabHost.newTabSpec(TAB4);
tabHost.addTab(obj.setIndicator(,
res.getDrawable(R.drawable.tab4))。setContent(
新的意图(这一点,Act4.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
物镜= tabHost.newTabSpec(tab5);
tabHost.addTab(obj.setIndicator(,
res.getDrawable(R.drawable.tab5))。setContent(
新的意图(这一点,Act5.class)));
tabHost.setCurrentTab(0);
}
公共无效switchTab(INT标签){
tabHost.setCurrentTab(标签);
}
}
请检查该链接。可能是对您有用。
Android的onActivityResult从来没有所谓的
How从TabHost活动返回结果(startActivityForResult)?
Android在选项卡使用startActivityForResult从嵌套的活动。
I'm developing an application that uses tabHost. In that 5 tabs, Each and every single tab can open multiple activities. My problem is that in last tab (5th tab) I did the functionality of camera capture so it open camera and capture image but before call onActivityResult it call the first tab(1st tab) and after that call onActivityResult of last tab. But I do not know why this happens?
My code is here:
For create multiple activities I use this: 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);
}
}
Please check this links. May be it is useful for you.
Android onActivityResult NEVER called
How to return a result (startActivityForResult) from a TabHost Activity?
Android Use startActivityForResult from a nested activity in a tab.
这篇关于问题onActivityResult在选项卡活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!