locked
How to detect Network Change when the App is in background in Windows Phone 8.1

    Question

  • Hi All,

    I need to develop an app in which Network change(Ex:Connection change from LTE to Wifi,Connecting to a New Wifi) should be detected when the app is in background.

    I used below code for Network Detection .But it is not firing the event when the app is in background.

    DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(ChangeDetected); Please provide solution.

    Thanks in advance.

    Wednesday, March 11, 2015 11:29 PM

Answers

  • I don't believe this is possible in a background task.

    Generally speaking the user has total control over connectivity and apps (and the user at the OS leve) control how they behave according to differing connectivity.

    What is the use case?


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Friday, March 13, 2015 6:32 AM
  • Hi Saikrupakar,

    Yes, there is limitation on background task.

    Background task has limitations for instance data limit or frequency limit, unlike desktop machine, we need to consider about the power usage for a mobile device, that's the reason we limit the background task.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 17, 2015 3:35 AM
    Moderator

All replies

  • Hi Saikrupakar,

    See Supporting your app with background tasks for more information about what kind of network triggers we supported in the background task. Simply write the code as you did can only fire the ChangeDetected event when the app is foreground.

    To know how to apply the background task, here is a quite detail example: https://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9/

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 12, 2015 1:35 AM
    Moderator
  • Thanks for the Reply.

    I checked background task documentation.It is mentioned as  background task will be triggered for every 15 minutes at least.In the mean time,if network connection changes,how it can be notified

    Thursday, March 12, 2015 1:30 PM
  • I don't believe this is possible in a background task.

    Generally speaking the user has total control over connectivity and apps (and the user at the OS leve) control how they behave according to differing connectivity.

    What is the use case?


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

    Friday, March 13, 2015 6:32 AM
  • Hi Saikrupakar,

    Yes, there is limitation on background task.

    Background task has limitations for instance data limit or frequency limit, unlike desktop machine, we need to consider about the power usage for a mobile device, that's the reason we limit the background task.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 17, 2015 3:35 AM
    Moderator