locked
[UWP] how to run an entire app while under the lockscreen RRS feed

  • Question

  • We have a couple of apps that users would like to run while turning the lock screen on so that they do not accidently touch the UI while walking (data gathering and/or monitoring activity).

    For Windows phone, there was the run under the lock screen:  PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled

    But, for UWP, we see that the only alternative (that we know of) is doing separate tasks - which doesn't make sense for our needs.

    Is there some setting we can leverage to let our entire app run under the lockscreen as the user wishes?

    Br, Karhu.


    Karhu Koti


    • Edited by karhukoti Tuesday, August 8, 2017 3:07 PM
    Tuesday, August 8, 2017 1:53 PM

Answers

  • @cc.cortes As we mentioned we were going to do above, we've tried the extended execution solution denoted at and it does work for us glad to say.

    This solution didn't seem obvious to us since the title had the words "while minimized" but we did see the one sentence in it about the lockscreen, so thought it might be worth trying.  Perhaps the title can be changed and the lockscreen sentence moved near the top of the paragraph.

    So we will mark our comment above as the answer.

    https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution

    Br, Karhu.


    Karhu Koti


    • Edited by karhukoti Friday, August 11, 2017 5:14 AM
    • Marked as answer by karhukoti Friday, August 11, 2017 5:14 AM
    Friday, August 11, 2017 5:14 AM

All replies

  • Hello,

    Please read the sticky posts, especially the Guide to posting: subject line tags 

    In UWP apps the only way to execute some code when app is suspended or closed is using BackgroundTasks. 


    Make the community better together


    Tuesday, August 8, 2017 2:44 PM
  • We also just saw this post also - we will try it out - it hints as it might work, but maybe it is only when "minimized" as the title says.

    I wonder why this functionality just isn't supported - I see several user questions asking on how to do this in various blogs.

    https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution#track-the-users-location


    Karhu Koti



    • Edited by karhukoti Tuesday, August 8, 2017 3:09 PM
    Tuesday, August 8, 2017 3:06 PM
  • @Breeze Liu

    Following behavior was changed since Win/WinPh 8.1 

    An app with a lock screen presence must declare one of the following types of background tasks:

    • Control Channel (Windows-only)
    • Timer
    • Push Notification

    Note that the app can run background tasks only if the user has placed that app on the lock screen.

    In UWP and 8.1 the app can run background tasks without putting it on Lock screen. If app doesn't use much resources (for example run loop every 5 second) then the best way is to use extended execution. But note that extended execution is available only when app doesn't closed. for other cases use background task. Note start from Creators update there is background task type which doesn't have any time limit for execution.



    Make the community better together


    • Edited by Azat Tazayan Wednesday, August 9, 2017 7:23 AM
    • Proposed as answer by Breeze Liu Wednesday, August 9, 2017 8:00 AM
    • Unproposed as answer by Breeze Liu Wednesday, August 9, 2017 8:04 AM
    Wednesday, August 9, 2017 7:23 AM
  • Hi Azat Tazayan,

    Thanks for pointing out it. I ignored that it was in UWP in the title and I am sorry for my unclear reply. Thanks again. But as the document tip, 

    Starting with Windows 10, you no longer need to place an app on the lock screen as a prerequisite for registering a background task for it.

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Edited by Breeze Liu Wednesday, August 9, 2017 8:06 AM
    Wednesday, August 9, 2017 8:00 AM
  • Thanks for the reply with this information, but this doesn't allow us to accomplish what we nor the user wants to do.

    @Breeze Liu Breeze, we see you are a MSFT CSG - is it possible to give feedback that users and app writers would like the possibility of "just running the app under the lock screen" such as was done prior.  (see above for the customer scenario).

    Br, Karhu.


    Karhu Koti


    • Edited by karhukoti Thursday, August 10, 2017 12:17 PM
    Thursday, August 10, 2017 12:17 PM
  • In Windows 10 the UWP platform enables your app to stay alive while under the lock screen for a couple different reasons:

    1. Background Media Playback: You can use either the older two-process model or the one process model introduced in the Anniversary Update to play audio while in the background: https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/background-audio

    2. Location Tracking: You can use Extended Execution to keep your foreground app alive under the lock screen while you are tracking location data. This is useful for scenarios like turn-by-turn directions or fitness tracking apps: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution

    You identified that the documentation could be updated to better indicate that this form of Extended Execution will allow your app to continue to run under the lock screen on Mobile devices. I will update that documentation

    3. Saving Data: When your app enters the Suspending state as the lock screen goes down, then you can request a limited amount of additional time to save data using Extended Execution with the Saving Data reason: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution

    You are correct that there is no method to generically continue to run under the lock screen, they are all based on user-centric scenarios. I am a member of the feature team and am very interested in understanding the scenario that you would like to enable for Windows Phone users.

    Thursday, August 10, 2017 10:16 PM
  • @cc.cortes As we mentioned we were going to do above, we've tried the extended execution solution denoted at and it does work for us glad to say.

    This solution didn't seem obvious to us since the title had the words "while minimized" but we did see the one sentence in it about the lockscreen, so thought it might be worth trying.  Perhaps the title can be changed and the lockscreen sentence moved near the top of the paragraph.

    So we will mark our comment above as the answer.

    https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution

    Br, Karhu.


    Karhu Koti


    • Edited by karhukoti Friday, August 11, 2017 5:14 AM
    • Marked as answer by karhukoti Friday, August 11, 2017 5:14 AM
    Friday, August 11, 2017 5:14 AM