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

Syntax

[Android.Runtime.Register("onStartCommand", "(Landroid/content/Intent;II)I", "")]
[System.Obsolete("deprecated")]
[return:Android.Runtime.GeneratedEnum]
public override sealed Android.App.StartCommandResult OnStartCommand (Android.Content.Intent intent, [Android.Runtime.GeneratedEnum] Android.App.StartCommandFlags flags, int startId)

Parameters

intent
The Intent supplied to Android.Content.Context.StartService(Android.Content.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
Additional data about this start request. Currently either 0, Android.App.Service.START_FLAG_REDELIVERY, or Android.App.Service.START_FLAG_RETRY.
startId
A unique integer representing this specific request to start. Use with Android.App.Service.StopSelfResult(int).

Returns

Documentation for this section has not yet been entered.

Remarks

Called by the system every time a client explicitly starts the service by calling Android.Content.Context.StartService(Android.Content.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 Android.App.Service.OnStart(Android.Content.Intent, System.Int32) and returns either Android.App.Service.START_STICKY or Android.App.Service.START_STICKY_COMPATIBILITY.

If you need your application to run on platform versions prior to API level 5, you can use the following model to handle the older Android.App.Service.OnStart(Android.Content.Intent, System.Int32) callback in that case. The handleCommand method is implemented by you as appropriate:

java Example

// This is the old onStart method that will be called on the pre-2.0
// platform.  On 2.0 or later we override onStartCommand() so this
// method will not be called.
@Override
public void onStart(Intent intent, int startId) {
    handleCommand(intent);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    handleCommand(intent);
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.
    return START_STICKY;
}

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 Android.OS.AsyncTask`3.

[Android Documentation]

Requirements

Namespace: Android.Locations
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0