Service.StopSelfResult(Int32) Method

Definition

Stop the service if the most recent time it was started was startId.

[Android.Runtime.Register("stopSelfResult", "(I)Z", "")]
public bool StopSelfResult(int startId);
[<Android.Runtime.Register("stopSelfResult", "(I)Z", "")>]
member this.StopSelfResult : int -> bool

Parameters

startId
Int32

int: The most recent start identifier received in onStart(Intent, int).

Returns

Attributes

Remarks

Stop the service if the most recent time it was started was startId. This is the same as calling Context.stopService(Intent) for this particular service but allows you to safely avoid stopping if there is a start request from a client that you haven't yet seen in onStart(Intent, int). Be careful about ordering of your calls to this function.. If you call this function with the most-recently received ID before you have called it for previously received IDs, the service will be immediately stopped anyway. If you may end up processing IDs out of order (such as by dispatching them on separate threads), then you are responsible for stopping them in the same order you received them.

See also:

Android reference for android.app.Service.stopSelfResult.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to