Udostępnij za pośrednictwem


Service.StopSelfResult(Int32) Method

Definition

Stop the service if the most recent time it was started was <var>startId</var>.

[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

The most recent start identifier received in #onStart.

Returns

Returns true if the startId matches the last start request and the service will be stopped, else false.

Attributes

Remarks

Stop the service if the most recent time it was started was <var>startId</var>. This is the same as calling android.content.Context#stopService 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.

<em>Be careful about ordering of your calls to this function.</em>. 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.

Java documentation for android.app.Service.stopSelfResult(int).

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

See also