tags:

views:

95

answers:

3

Hi, Ive got two activities in the same application. the first one is with gui(main activity) the second one is a listener which works infinite without gui.

Wierd problem occurs:

i am running the second activity with a diffrent thread so i could keep on manipulate the gui..

but for some reason, the gui losing it's focus for some reason, only when i press 'home' and come back to it, then i can continune maniuplate the gui.

it feels like after i launch the second activity, the gui activity(the main) is losing the focus. how come?

in my mainactivity i have:

setContentView(R.layout.main);

and its setted as the launcher in the manifest.

thanks,

ray.

+1  A: 

I wouldn't implement your background activity as an Activity. Once you launch an activity it'll always be focused and brought to the foreground. It sounds like what you want to do is launch a runnable (thread) from your main activity and have this thread instantiate a normal class (non-Activity) and do whatever work it needs to do.

You may also consider implementing it as a Service

Ricardo Villamil
A: 

I don't think trying to have more then one Activity open at a time is right according to the "Android Model".

According to the guide:

"An activity presents a visual user interface for one focused endeavor the user can undertake"

If it had any GUI elements associated with it you might want to create a dialog. But if it is truly a background operation do what the guy before me said.

ddcruver
Hi, I wasnt trying to have one activity open at a timey, just to open some activity and remine at the previouse activity gui
rayman
Understood, but I believe an Activity for your background is not the most appropriate thing to do. A Thread or Runnable should be used for background issues or maybe a service or broadcast listener/recievers. I just believe that you starting an activity is the reason for you loosing focus.
ddcruver
Yes, but if i wanna start local service, how would i do it without starting some activity that have to run it? you cant run local service by itself, you must some activity to run it.
rayman
I am just starting to look into services but I believe that you main activity can start the service.
ddcruver