IT tutorials
 
Mobile
 

Windows Phone 8 : Building Location Aware Apps - Getting Started with Location (part 2) - Background Location Tracking

1/27/2015 3:07:19 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Background Location Tracking

In Windows Phone 7.5, apps that made use of location tracking were subject to events being lost when deactivated. When the app was dormant or tombstoned, PositionChanged event handlers would be discarded—lost forever, leaving the app without any knowledge of changes in location for the period before reactivation.

This has changed in Windows Phone 8, which allows only a single app to be in execution at any one time unless that app is a location tracking app, in which case it can continue to run in the background while a different app is running in the foreground.

To nominate your app as a location tracking app, add a BackgroundExecution element to the DefaultTask element in your project’s WMAppManifest.xml file, as shown:

<DefaultTask Name="_default" NavigationPage="MainPage.xaml" >
    <BackgroundExecution>
        <ExecutionType Name="LocationTracking" />
    </BackgroundExecution >
</DefaultTask>

With this in place, your app will continue to run as long as it remains subscribed to a Geolocator object’s PositionChanged event.

When your app is running in the background, it is important to stop all tasks not related to location tracking. To be notified when your app is running in the background, subscribe to the RunningInBackground event of the PhoneApplicationService. This can be done in your project’s App.xaml file as shown:

<Application.ApplicationLifetimeObjects>

    <shell:PhoneApplicationService
        RunningInBackground="HandleRunningInBackground"
        ... />
</Application.ApplicationLifetimeObjects>

The event handler is placed in your App.xaml.cs file, like so:

void HandleRunningInBackground(object sender, RunningInBackgroundEventArgs e)
{
    /* Stop all tasks not related to location tracking. */
}

The RunningInBackground event enables your app to suspend unnecessary tasks, such as updating the UI.


Note

Only one location tracking app can be running in the background at any time. The most recently opened location tracking app takes precedence and causes any existing location tracking apps to be made dormant or tombstoned.


Although location tracking apps are currently the only type of app that can be enabled to run in the background, plan to see other types of background apps in the future.

Testing Apps That Use the Geolocator

The Windows Phone emulator includes a tool for simulating location tracking, which can be accessed by clicking the Additional Tools button on the emulator menu , and then selecting the Location tab on the Additional Tools windows.

The location simulator works in two modes: a live mode that allows you to interact with the map to send location data to the emulator as soon as you click on the map and a playback mode that causes the location simulator to step through a sequence of map points, which you enter by clicking on the map (see Figure 2).

Image

FIGURE 2. Location simulator.

Map points can be saved to a file and loaded again at a later time.


Note

The Play button is enabled only when the Live button is toggled off.


When using the location simulator, any Geolocator instances in your app respond as though they are receiving actual location data, giving you the opportunity to test your app’s geo location features.

 
Others
 
- Windows Phone 8 : Building Location Aware Apps - Getting Started with Location (part 1) - Geolocator Class
- Windows Phone 8 : Building Location Aware Apps - Location Sensing Technologies
- Windows Phone 8 : Range Controls (part 2) - Progress Indicator, Slider , ScrollBar
- Windows Phone 8 : Range Controls (part 1) - ProgressBar
- Windows Phone 8 : Items Controls - ListBox, ComboBox
- Windows Phone 8 : LinkedIn (part 3) - Posting a Message, The Feeds Filter
- Windows Phone 8 : LinkedIn (part 2) - Accessing LinkedIn Content, Responding to a LinkedIn Post
- Windows Phone 8 : LinkedIn (part 1) - Configuring Your LinkedIn Account
- Windows Phone 8 : Twitter (part 2) - Checking for Tweets, Responding to a Tweet, Checking Twitter Notifications
- Windows Phone 8 : Twitter (part 1) - Configuring Your Twitter Account
 
 
Top 10
 
 
Facebook
 
Technology FAQ
- Microsoft ebs security server configuration
- IIs7 on Windows server 2003
- How to Configure Failover Clusters With Win 2008 Server R2?
- Windows 2008 Network Load Balancing
- Windows Server 2008 - Group Policy Management - Remove Computer Management
- Remove shortcuts possibility in a web page or to put in favorite
- HTA Dynamic Drop Down List
- IIS host header and DNS
- VMware or MS Virtual Server?
- Adobe Acrobat 9 inserting tab pages
programming4us programming4us