Widget starting a service also starts main activity

Posted by Nick on Stack Overflow See other posts from Stack Overflow or by Nick
Published on 2010-05-03T22:37:16Z Indexed on 2010/05/03 23:08 UTC
Read the original article Hit count: 236

Filed under:

Hi,

I have a widget that is supposed to start and stop a service (start it when it's not running, stop it when it is). This is working fine, however, each time the service is started, my app's main activity is also launched, which I don't want. If I remove the MAIN-intent-filter ( <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
) from the app's manifest, it works as I want it to (without launching the main-activity, just the service), but then I obviously don't have a main activity anymore...

This is how I start the service (I would assume this is the normal way, and I can't see any reference to what might cause the MAIN intent to fire):

Intent svc = new Intent(this, OnOffService.class);
startService(svc);

Thanks,
Nick

© Stack Overflow or respective owner

Related posts about android