Issues opening Activity from Service

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Issues opening Activity from Service

Postby Jeppebm » Tue Nov 24, 2009 5:36 pm

Greetings!

I'm starting an activity from a background service, in order to prompt the user for information (I'm well aware that this is not preferable from a user's point of view).

The problem is that when the activity starts, the back-button directs the user back to the activity that originally started the service! I want the back-button to go back to the activity that was active when the activity was started by the service, be it another application, home screen or similar.

Is it a context issue, or wrong launchmode or something?

Any help is greatly appreciated, thanks!

/ Jeppe
Jeppebm
Freshman
Freshman
 
Posts: 3
Joined: Tue Nov 24, 2009 5:25 pm

Top

Postby qlimax » Tue Nov 24, 2009 9:05 pm

try to finish your activity just after you started the service,


startService(...);
finish();

bye
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby Jeppebm » Wed Nov 25, 2009 12:58 am

Thanks, but I don't want to close the activity after I started the service. The service is started when I press a button in the activity, but the activity lives on until user closes it.

I might not have made myself clear about that :)
Jeppebm
Freshman
Freshman
 
Posts: 3
Joined: Tue Nov 24, 2009 5:25 pm

SOLVED

Postby Jeppebm » Sun Dec 13, 2009 5:27 pm

I managed to fix it by setting the launchMode to singleInstance. By doing that, the activity starts in its own task.
Jeppebm
Freshman
Freshman
 
Posts: 3
Joined: Tue Nov 24, 2009 5:25 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 3 guests