I ha开发者_运维技巧ve my main activity going and a button going to a different activity. When I go to the other activity my main activity stops. How would I keep the main activity going?
Thanks in advance.
How would I keep the main activity going?
You wouldn't.
Depending on what it is that you are doing, you might consider moving it to a Service
.
Yes, you can keep your main Activity running. My way is use a "CHEAT".
Example your main Activity is A, in A we have button btnA. Click this btnA will open activity B.
You create a tab bar with 2 tab contains A and B. After initialize tab bar, call
tabHost.getTabWidget.setVisibility(View.GONE);
to hide this tab. So you only see main Activity visible.
When btnA is clicked, only need to switch tabHost to B
tabHost.setCurrentTab(1);//1 is index of Activity B
This question & answer is similar with your question. You can refer to it.
Activities and sub activities
精彩评论