locked
How to continuously monitor GPS position and Bluetooth (rfcomm) in the background

    Question

  • Hi,

    In my application (Maps Pro, already in the Windows 8 Store), I track the user's position continuously from two different sources, either:

    • Internal GPS via the Geolocator API
    • External Bluetooth GPS via the RFCOMM Protocol

    Everything works well when the application is in the foreground but as soon as the application is suspended (for instance, switching to the Photo app), code is not executed and i lose information.

    I looked it up, especially the background Geolocation Sample from MS but it is not as good as what I want to do. In the MS example, they poll the user's position every (at least) 15 minutes, using the Windows.ApplicationModel.Background.TimeTrigger class. In the documentation:

    http://msdn.microsoft.com/en-us/library/windows/apps/jj160504.aspx

    It says that the delay cannot be less than 15 minutes. In my case, 15 minutes is way too much, i need to monitor the position continuously in the background. It looks like the Maintenance Trigger is a no-go for me:

    http://msdn.microsoft.com/fr-fr/library/windows/apps/windows.applicationmodel.background.maintenancetrigger.aspx

    Microsoft also provide a geofencing API but I don't believe it will let me do what I want. From the SystemTriggers, I can't seem to find one that would allow me to run the code that I want:

    http://msdn.microsoft.com/fr-fr/library/windows/apps/windows.applicationmodel.background.systemtriggertype.aspx

    Would the "userAway" trigger allow me to run code that would run continuously?

    I need to monitor both the Geolocator information and the information i get from the Bluetooth Sensor. I also looked up the RfcommConnectionTrigger but it is only available for Windows Phone.

    Thanks for any indications you can give me!

    Fabien

    Monday, July 21, 2014 8:21 PM

All replies

  • Does this help?
    http://msdn.microsoft.com/library/windows/apps/jj247548(v=vs.105).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.

    Tuesday, July 22, 2014 7:17 PM
    Moderator
  • Thanks for your answer,

    It does not really help, that article you sent is for detecting geolocation in the foreground in WP8 and i am looking at geolocation in the background in W8.

    From the other articles on that page, it seems that WP8 has less restrictions as to what can run in the background. The "ID_CAP_LOCATION" task does not exist in the W8 package manifest

    Fabien

    Wednesday, July 23, 2014 7:24 AM
  • Sorry, I meant to give you this one:

    http://msdn.microsoft.com/en-us/library/windows/apps/jj681691(v=vs.105).aspx

    This is about running geolocation in the background.


    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.

    Wednesday, July 23, 2014 1:46 PM
    Moderator
  • This is the one that only works in Windows Phone 8, I need to make it work in Windows 8, sorry
    Wednesday, July 23, 2014 1:52 PM