Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

BackgroundExecutionManager.RequestAccessAsync() | requestAccessAsync() method

Requests access for an app to run background tasks.

Syntax


Windows.ApplicationModel.Background.BackgroundExecutionManager.requestAccessAsync().done( /* Your success and error handlers */ );

Parameters

This method has no parameters.

Return value

Type: IAsyncOperation<BackgroundAccessStatus>

The object, bound to the calling app, that is used to request that the app be added to the lock screen's apps list. When the operation completes, it returns a member of the BackgroundAccessStatus enumeration that specifies the outcome.

Remarks

On Windows, this method presents the user with a dialog box that requests that an app be added to the lock screen. On Windows Phone 8.1, this method does not prompt the user, but must be called before registering any background tasks. On Windows 10 Insider Preview, Windows Server Technical Preview, and Windows 10 Mobile Insider Preview, you do not need to add the app to the lock screen before the app registers background tasks, but you still need to call RequestAccessAsync to request background access. Due to these differences in behavior, the values returned by this method have different meanings depending on which type of app is calling it.

This method must be called from the UI thread. If it is not called from the UI thread, in some cases you can see error code 0x80070490 (ERROR_NOT_FOUND) in place of 0x80070005 (E_ACCESSDENIED). Receipt of error code 0x80070490 is a good indication that you are not calling from the UI thread.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.winmd

See also

BackgroundExecutionManager
RequestAccessAsync(String)

 

 

Show:
© 2015 Microsoft