Language

SettingInjectorService.OnStartCommand Method

Definition

Called by the system every time a client explicitly starts the service by calling StartService(Intent), providing the arguments it supplied and a unique integer token representing the start request.

[Android.Runtime.Register("onStartCommand", "(Landroid/content/Intent;II)I", "")]
public override sealed Android.App.StartCommandResult OnStartCommand(Android.Content.Intent? intent, Android.App.StartCommandFlags flags, int startId);
[<Android.Runtime.Register("onStartCommand", "(Landroid/content/Intent;II)I", "")>]
override this.OnStartCommand : Android.Content.Intent * Android.App.StartCommandFlags * int -> Android.App.StartCommandResult

Parameters

intent
Intent

The Intent supplied to StartService(Intent), as given. This may be null if the service is being restarted after its process has gone away, and it had previously returned anything except Android.App.Service.START_STICKY_COMPATIBILITY.

flags
StartCommandFlags

Additional data about this start request. Currently either 0, Android.App.Service.START_FLAG_REDELIVERY, or Android.App.Service.START_FLAG_RETRY.

startId
Int32

A unique integer representing this specific request to start. Use with StopSelfResult(Int32).

Returns

The return value indicates what semantics the system should use for the service's current started state. It may be one of the constants associated with the START_CONTINUATION_MASK bits. Value is one of the following: START_STICKY_COMPATIBILITY; START_STICKY; START_NOT_STICKY; START_REDELIVER_INTENT

Attributes

Remarks

Called by the system every time a client explicitly starts the service by calling Context.startService(Intent), providing the arguments it supplied and a unique integer token representing the start request. Do not call this method directly.

For backwards compatibility, the default implementation calls onStart(Intent, int) and returns either START_STICKY or START_STICKY_COMPATIBILITY.

Note that the system calls this on your service's main thread. A service's main thread is the same thread where UI operations take place for Activities running in the same process. You should always avoid stalling the main thread's event loop. When doing long-running operations, network calls, or heavy disk I/O, you should kick off a new thread, or use AsyncTask.

Android reference for android.location.SettingInjectorService.onStartCommand.

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