m Sheta
m Sheta

Reputation: 11

how to disable my services in my android application?

i am beginner in android development and i develop application with activties and services . now i want to add new option which that disable application. how to stop this services

Upvotes: 1

Views: 2949

Answers (3)

Martin
Martin

Reputation: 11875

There is no need to stop the service in normal execution. If needed the OS will do that for you.

If you Service has started any background threads then you should stop those of course. But that is done the normal Java way.

You should read Multitasking the Android Way.

Upvotes: 0

Jayy
Jayy

Reputation: 14738

To start the service:

startService(new Intent(ThisActivity.this, YourService.class));

To stop the service:

stopService(new Intent(ThisActivity.this, YourService.class));

They can be called from anywhere within your Activity.

Upvotes: 1

Lukas Knuth
Lukas Knuth

Reputation: 25755

You should check the Service Lifecycle.

Upvotes: 0

Related Questions