简体   繁体   中英

ClipBoard.SetText throws exception when application is running under lock screen Windows phone 8

I'm building a Windows Phone application which will allow the user to set text remotely even when the application is running under lockscreen.

When I called ClipBoard.SetText("some data") when the application was under lock screen, it threw the following exception:

at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Clipboard_SetText(String text)
at System.Windows.Clipboard.SetText(String text)
...

Any suggestion or workaround for this issue?

According to [msdn] 1 The Clipboard.SetText Method is restricted to the usage of a user-initiated action only. Therefore i would not expect .SetText to work in a locked mode.

Well as a App User this makes sense . I wouldn't wan't a app messing around with my clipboard while i'm not using the app. Say, I copy a number and by the time i want to paste the number another app replaced the number with another text....

Copied from Remarks: ... These APIs can only be invoked from within a context that is determined by the Silverlight runtime to be in response to a user-initiated action. For example, clipboard access is valid from within a handler for a Click or KeyDown event. For examples of situations that are not considered user-initiated, clipboard access is not valid from a handler for Loaded or from a constructor.

What about: The App persists the text in a temporary store (persisting setting or variable instance) and updates the Clipboard whenever the user returns to the app?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM