Provides methods that let an app ask to be added to the lock screen's apps list or query its current access to background activity and badge updates on the lock screen.
Syntax
var backgroundExecutionManager = Windows.ApplicationModel.Background.BackgroundExecutionManager;
Attributes
- StaticAttribute(Windows.ApplicationModel.Background.IBackgroundExecutionManagerStatics, NTDDI_WIN8)
- VersionAttribute(NTDDI_WIN8)
Members
The BackgroundExecutionManager class has these types of members:
Methods
The BackgroundExecutionManager class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| GetAccessStatus() | Gets the ability of the calling lock screen app to perform background activity and update its badge. |
| GetAccessStatus(String) | Gets the ability of a specific lock screen app to perform background activity and update its badge. |
| RemoveAccess() | Removes the calling app from the lock screen's apps list. |
| RemoveAccess(String) | Removes a specific app from the lock screen's apps list. |
| RequestAccessAsync() | Presents the user with a dialog box that requests that the calling app be added to the lock screen. |
| RequestAccessAsync(String) | Presents the user with a dialog box that requests that the specified app be added to the lock screen. |
Remarks
Because apps with a presence on the lock screen are allowed to run some tasks in the background, certain classes of apps will require the access gained through this class in order to execute their core scenarios.
For a full sample demonstrating the use of this class, see the Lock Screen Sample on the Windows Dev Center.
Examples
This example shows the use of this class to add an app to the lock screen and grant it the ability to perform background tasks.
var Background = Windows.ApplicationModel.Background; var promise = Background.BackgroundExecutionManager.requestAccessAsync().then( function(result) { switch (result) { case Background.BackgroundAccessStatus.denied: // Disabled by the user. break; case Background.BackgroundAccessStatus.allowedWithAlwaysOnRealTimeConnectivity: // Added to list of background apps. // Set up background tasks; can use the network connectivity broker. break; case Background.BackgroundAccessStatus.allowedMayUseActiveRealTimeConnectivity: // Added to list of background apps. // Set up background tasks; cannot use the network connectivity broker. break; case Background.BackgroundAccessStatus.unspecified: // The user didn't explicitly disable or enable. break; } });
Removing an app from the lock screen.
var Background = Windows.ApplicationModel.Background;
Background.BackgroundExecutionManager.removeAccess();
This example shows how to query for an app's lock screen state.
var Background = Windows.ApplicationModel.Background; var result = Background.BackgroundApplications.getAccessStatus(); switch (result) { case Background.BackgroundAccessStatus.denied: // Disabled by the user. // Cannot display on the lock screen or set up background tasks. break; case Background.BackgroundAccessStatus.allowedWithAlwaysOnRealTimeConnectivity: // Added to list of background applications. // Can display on the lock screen. // Can set up background tasks and use the network connectivity broker. break; case Background.BackgroundAccessStatus.allowedMayUseActiveRealTimeConnectivity: // Added to list of background applications. // Can display on the lock screen. // Can set up background tasks but cannot use the network connectivity broker. break; case Background.BackgroundAccessStatus.unspecified: // The user didn't explicitly disable or enable. break; }
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 12/4/2012