1

I have 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.

Christian
  • 958
  • 5
  • 23
  • 52
  • In general, you can't do this. What is it you want to achieve? Continual processing needs the use of separate threads, services etc. – Squonk Apr 10 '11 at 00:39

2 Answers2

4

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

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

Community
  • 1
  • 1
anticafe
  • 6,816
  • 9
  • 43
  • 74