Over a million developers have joined DZone.

Custom accelerometer motions for the Windows Phone emulator

· Mobile Zone

Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud, brought to you in partnership with IBM.

The new Windows Phone Mango SDK introduced a testing tool, that is tied to the device emulator, allowing developers to simulate location data and readings from the accelerometer sensor (now it also allows taking screenshots). This tool has a pre-set motion, called Shake.


But that’s about it out-of-the-box. What would be great is having custom motions that can later on be tested multiple times with multiple applications. A lot of developers messing with the toolset don’t know that in fact, it is possible to add those multiple motions by simply building a custom XML file and placing it in Program Files\Microsoft XDE\1.0\sensordata\acc.

I wrote a Windows Phone application that automatically captures data from the accelerometer sensor and stores it in the isolated storage.


When the capture is complete, the data can be pulled from the phone through the IsolatedStorageExplorer tool, also available in the Mango toolset (located in Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool). You can execute this command, if you are running the application in the emulator:

ISETool ts xd 87fbb02b-db71-4a52-bfcb-f7759f84a465 D:\Temporary

Where the GUID following xd represents the application ID declared in the WMAppManifest.xml file. The path at the end of the command is the destination where pulled data is placed.

If the application is located on a physical device (for better accelerometer readings and real-world testing), execute this command:

ISETool ts de 87fbb02b-db71-4a52-bfcb-f7759f84a465 D:\Temporary

Notice that instead of xd there is now de (device).

Once you pull the data from the Isolated Storage, you will see that the files you recorded are in the root of the IsolatedStorage folder. You need to copy them to Program Files\Microsoft XDE\1.0\sensordata\acc for the custom motions to be registered.

If you copy custom motions to the acc folder while the testing tool is running, you will have to close the testing tool (the emulator can continue running) and re-open it again for new motions to be shown in the list.

You can download the source code here.

You can download the XAP here.

The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}