Service.StartForeground Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| StartForeground(Int32, Notification) |
If your service is started (running through |
| StartForeground(Int32, Notification, ForegroundService) |
An overloaded version of |
StartForeground(Int32, Notification)
If your service is started (running through Context#startService(Intent)), then
also make this service run in the foreground, supplying the ongoing
notification to be shown to the user while in this state.
[Android.Runtime.Register("startForeground", "(ILandroid/app/Notification;)V", "")]
public void StartForeground (int id, Android.App.Notification? notification);
[<Android.Runtime.Register("startForeground", "(ILandroid/app/Notification;)V", "")>]
member this.StartForeground : int * Android.App.Notification -> unit
Parameters
- id
- Int32
The identifier for this notification as per
NotificationManager#notify(int, Notification)
NotificationManager.notify(int, Notification); must not be 0.
- notification
- Notification
The Notification to be displayed.
- Attributes
Remarks
Java documentation for android.app.Service.startForeground(int, android.app.Notification).
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.
See also
Applies to
StartForeground(Int32, Notification, ForegroundService)
An overloaded version of #startForeground(int, Notification) with additional
foregroundServiceType parameter.
[Android.Runtime.Register("startForeground", "(ILandroid/app/Notification;I)V", "", ApiSince=29)]
public void StartForeground (int id, Android.App.Notification notification, Android.Content.PM.ForegroundService foregroundServiceType);
[<Android.Runtime.Register("startForeground", "(ILandroid/app/Notification;I)V", "", ApiSince=29)>]
member this.StartForeground : int * Android.App.Notification * Android.Content.PM.ForegroundService -> unit
Parameters
- id
- Int32
The identifier for this notification as per
NotificationManager#notify(int, Notification)
NotificationManager.notify(int, Notification); must not be 0.
- notification
- Notification
The Notification to be displayed.
- foregroundServiceType
- ForegroundService
must be a subset flags of manifest attribute
android.R.attr#foregroundServiceType flags.
- Attributes
Remarks
Java documentation for android.app.Service.startForeground(int, android.app.Notification, 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.