Sandeep
Sandeep

Reputation: 687

How to stop android service?

I have created a android service. I start the service and stop the service using startService(intent) and stopService(intent).

My problem is that even i stop the service; it starts again without any explicit call to startService.

Any help appreciated

Upvotes: 4

Views: 4427

Answers (1)

tony gil
tony gil

Reputation: 9554

without proper code samples, this is difficult, but chances are that you have a bound services that is not unbound yet.

in case you dont have it bound, "this.stopSelf()" from within the service is one of the ways to do the trick:

public class BatchUploadGpsData extends Service {
    @Override
    public void onCreate() {
        Log.e(TAG, "here i am, rockin like a hurricane.   onCreate service");
        this.stopSelf();
    }

this is an actual code snippet from testing code that works on android 2.2 and up

Upvotes: 4

Related Questions