locked
Is there any event in windows universal app (wp8.1&win8.1) that fires when screen locked and unlocked with in the app?

    Question

  • Hi All,

    Is there any event in windows universal app (wp8.1&win8.1) that fires when screen locked and unlocked with in the app

    Right now, I am using this below mentioned event

    Window.Current.VisibilityChanged += CurrentWindow_VisibilityChanged;, but it fires even when app relaunches.

    Please anybody help me to solve this issue.

    Thursday, January 22, 2015 12:29 PM

Answers

  • AFAIK, there aren't any. Keep in mind that your app isn't going to be able to respond to these kinds of events because your app won't be in the foreground. You have to use a background task for this.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Badri Bharath Tuesday, January 27, 2015 5:36 AM
    Friday, January 23, 2015 3:12 PM
    Moderator

All replies

  • The UserPresent and UserAway System triggers should fire in these cases.  See
    https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.background.systemtriggertype.aspx


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, January 22, 2015 7:14 PM
    Moderator
  • Thanks for your early reply. but, those are system triggers used in background task. I want an event that fires when screen gets locked. like this...(a networkstatuschangedevent)

    NetworkStatusChangedEventHandler

    networkStatusCallback = newNetworkStatusChangedEventHandler(OnNetworkStatusChange);

    Friday, January 23, 2015 1:35 PM
  • AFAIK, there aren't any. Keep in mind that your app isn't going to be able to respond to these kinds of events because your app won't be in the foreground. You have to use a background task for this.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Badri Bharath Tuesday, January 27, 2015 5:36 AM
    Friday, January 23, 2015 3:12 PM
    Moderator
  • Thanks for your wonderful support and solutions. :)
    Tuesday, January 27, 2015 5:36 AM