GEO Magazin Juli 2013
Microsoft Store Creating a Location-Aware App with Geofencing The ever-increasing adoption of mobile devices is propelling the creation of location-aware apps. The opportunities for apps that know and react to a user’s location are virtually limitless. Windows 8 included geolocation from the beginning, giving developers an easy way to determine the current location of a device. The Windows simulator even includes support for testing this feature. With Windows 8.1, these APIs have been extended with the concept of geofencing. A geofence is a defined region around a GPS location that can be registered with Windows so an app can receive notifications when the device enters or leaves that region.
Let’s say you’re a service technician with a dozen house calls to make in a given day. What if the app that manages your appointments could automatically send a text message to the home owner when you were five minutes away? Or suppose an amusement park wanted to announce the presence of characters, but only to people within a certain proximity of the character to limit the number of people that might show up.
July 2013 Lighting your financial future Choosing your new vehicle may be difficult, but when it comes to your auto loan, the choice is clear. GeoVista Credit Union offers low rates, convenient terms and quick approval. Your rate could be as low as 2% APr. for 36 months (for 2009 - current year models) You can even apply for your loan before. Sep 18, 2014 How To Train your Dog NOT to PULL on the Leash! STOP CHASING or LUNGING at CARS on a Walk! - Duration: 13:15. Zak George’s Dog Training Revolution 2,603,401 views. Jul 3, 2013 - Issuu is a digital publishing platform that makes it simple to publish magazines, catalogs, newspapers, books, and more online. Easily share your publications and get them in front of Issuu's millions of monthly readers. Title: UT Nieuws Magazine Juli 2013, Author: Redactie U-Today, Name: UT Nieuws.
The possibilities are endless. This article will explore the use of geofences in Windows 8.1. However, the geofencing API is also shared with Windows Phone 8.1, which means you can implement the same features on both platforms. You’ll learn how to add geofences to your location-based app, plus how to handle events when the app is in the foreground and how to handle notifications when the app is in the background.
Adding Geolocation Support Because geofences are part of the geolocation API in the Windows SDK, you must add support for this API to your app before you can use it. Luckily, Windows Store apps need very little setup to use geolocation. In fact, the only requirement is the package appxmanifest must include the Location capability. To add this, open the solution’s appxmanifest in the designer and check “Location” in the capabilities tab, as shown in Figure 1. Figure 1 Enable Location Capability Once this capability has been added to your project, the app is able to access Windows location services through the geolocation API if given permission by the user.
This capability also adds a Permissions section to the app’s Settings charm, which lets the user enable and disable access to the device’s location, as shown in Figure 2. Figure 2 Permissions Settings In addition to granting access to the location services on an individual app level, Windows can disable location services for the entire device. Location services are enabled by default in Windows, but users or systems administrators are free to change this by going to Control Panel Hardware and Sound Location Settings.
Because there are several different scenarios that can affect the app’s access to the device’s location, it’s important your app know when there’s a change to this access. The SDK lets the app monitor its access to the location services through an event exposed in the DeviceAccessInformation class in the Windows.Devices.Enumeration namespace. An instance of the DeviceAccessInformation class is created through a static method, CreateFromDeviceClass, which takes a DeviceClass enumeration that specifies the hardware device on which you want information. For the location services, this value is DeviceClass.Location. After creating an instance of DeviceAccessInformation, you can determine the current access level from the CurrentStatus property and listen for access changes through the AccessChanged event, like so. MonitoredGeofenceStates monitor = MonitoredGeofenceStates.Entered MonitoredGeofenceStates.Exited MonitoredGeofenceStates.Removed; bool singleUse = true; Geofence geofence = new Geofence('myUniqueId', shape, monitor, singleUse); By default, a device must remain on the monitored side of a boundary for 10 seconds before an app is notified. This keeps the system from firing multiple events if a device is right on the edge and moving back and forth.
This value is the DwellTime and can be set to any TimeSpan greater than 0. The same DwellTime will be used for entering and exiting the area. Therefore, if you need different values, you’ll have to create two geofences, one for entering and one for exiting. The following uses the third constructor by setting the DwellTime to 20 seconds.
TimeSpan dwellTime = new TimeSpan(0, 0, 20); Geofence geofence = new Geofence('myUniqueId', shape, monitor, singleUse, dwellTime); The final constructor allows you to set the StartTime and Duration of the geofence. A geofence will become active once the StartTime is in the past.
By default, the StartTime is set to 0 or the beginning of a time handled in a DateTime class. If a geofence is created with a StartTime in the past and the device is already inside the defining area, the Entered state will be reported once the DwellTime has passed.
In conjunction with the StartTime, you can define a Duration for how long the geofence will be active from the StartTime. If the Duration is set to 0 (the default value), the geofence remains active as long as it’s registered to be monitored. When a Duration value has been set, the app will be notified of its expiration if the Removed monitor state is selected. Here’s the final constructor, which sets a StartTime for midnight, Jan. 1, 2015, and a duration of 365 days. DateTime startTime = new DateTime(2015, 1, 1); TimeSpan duration = new TimeSpan(365, 0, 0, 0, 0); Geofence geofence = new Geofence( 'myUniqueId', shape, monitor, singleUse, dwellTime, startTime, duration); Using Geofences in the Foreground After a geofence has been created, the next step is to register it to be monitored so your app can receive notifications about it.
This is handled through a GeofenceMonitor instance. Each app will have a single GeofenceMonitor that can be accessed through the static property of GeofenceMonitor.Current.
The GeofenceMonitor maintains a list of all registered geofences in the Geofences property, which is an IList. Adding and removing geofences from this list is as easy as using the IList methods you’re used to, such as Add and Remove. Once an app registers a geofence, it’s persisted to disk. This means you only need to register the geofence once, even between app uses. If you attempt to register a geofence with a duplicate id, an error will be generated, so it’s a good policy to verify the id isn’t present prior to registration. GeofenceMonitor.Current.GeofenceStateChanged += GeofenceStateChanged; When the GeofenceStateChanged event is fired, the affected geofences are not sent in the args property, which is common for most changed event handlers.
To get the notification about what has changed, you call the ReadReports method of the current GeofenceMonitor. This will return a collection of recent monitor notifications, sorted in a descending timestamp order, that have happened for the app.
Geo Magazin Juli 2013 En
Each notification is represented by a GeofenceStateChangeReport class. The GeofenceStateChangeReport has a Geofence property that references the geofence whose state has changed, and a Geopostion property that provides the location of the device responsible for the state being changed. It also has a NewState property, which is a GeofenceState enum that identifies which monitoring state was triggered. Finally, there’s a RemovalReason property, which is a GeofenceRemovalReason enum that can be either Used or Expired.
The default is Used for any event and doesn’t mean the geofence has been removed. It simply provides a removal reason if the NewState value is Removed. The number of reports returned by ReadReports is controlled by Windows. There’s no guarantee how many reports will be stored or for how long, so if you need to maintain any information, you’ll need to keep a separate copy in the app.
Geo Magazin Juli 2013 Download
Figure 5 is an example of handling the GeofenceStateChanged event.