Mobile Zone is brought to you in partnership with:

Hey there! My name is Adam, and I'm a Technical Evangelist at Microsoft where I spend time focusing on Windows, Windows Phone, and Windows Azure. Adam is a DZone MVB and is not an employee of DZone and has posted 30 posts at DZone. You can read more from them at their website. View Full User Profile

Android to Windows Phone 8: Connect to the network

06.21.2013
| 1989 views |
  • submit to reddit

It’s more than likely that a Windows Phone app will need to work with data that resides on the Internet. For example, an app may aggregate data from various news sources using RSS feeds. Consuming this type of data in a Windows Phone app is very similar to consuming it in an Android app. In this post I’ll show you how to get your Windows Phone app connected to the network.

In order for a Windows Phone application to access the Internet, it must have the ID_CAP_NETWORKING capability enabled in its app manifest. By default, when you create a new Windows Phone application using Visual Studio the ID_CAP_NETWORKING capability is enabled for you. To ensure the capability is enabled do the following:

Double-click the WMAppManifest.xml file in Visual Studio’s Solution Explorer.

Click on the Capabilities tab in the Manifest Designer and make sure the checkbox next to ID_CAP_NETWORKING is checked.

Android tip
To connect to a network in Android you would need to declare the following manifest permission:

<uses-permission android:name=”android.permission.INTERNET” />

Your Windows Phone app can now access network resources.

Before proceeding, there are a few things regarding the ID_CAP_NETWORKING capability that you should be aware. First, this capability is automatically enabled when an app is deployed to a Windows Phone or the Windows Phone Emulator from Visual Studio. If your app requires networking, make sure you enable the capability in the manifest file using the steps outlined above. Failing to do so could cause the app to fail when it’s installed on a user’s phone.

Windows Phone tip
You can learn more about App capabilities for Windows Phone at http://aka.ms/WPAppCapabilities.

Second if your app uses networking capabilities to publish or make available location data obtained from the Location Service API to any other service or person (including ad networks), your app must do the following to implement a method of opt-in consent:

  • Provide a privacy policy, which must be persistently accessible from within the app (and may also be made available in app details by populating the Privacy URL field in Dev Center) and must describe how the location information will be accessed, used or shared.
  • Obtain the user’s express permission in the app user-interface before accessing, uploading or sharing the information as described.
  • Provide a mechanism through which the user can later opt out of having the location information accessed, uploaded or shared. Your app must periodically remind users or provide a visual indicator that location data is being sent to any other service or person.

Third, similar to location data, if your app uses networking capabilities to (a) access and upload a user’s Contact, Photos, Phone number, SMS history, Browsing history or any other data reasonably consider personal in nature, or if your app shares any of the foregoing information with third-party services or individuals, or (b) share any unique device or user IDs, combine with user information, with third-party services or individuals, your app must do the following to enable opt-in consent:

  • Provide your privacy policy, which must be persistently accessible from within the app (and may also be made available in app details by populating the Privacy URL field in Dev Center) and must describe how the information will be accessed, used or shared.
  • Obtain the user’s express permission in the app user-interface before accessing, uploading or sharing the information as described.
  • Provide a mechanism through which the user can later opt out of having the information accessed, uploaded or shared.
Windows Phone tip
You can learn more about App policies for Windows Phone at http://aka.ms/WPAppPolicies.
Published at DZone with permission of Adam Grocholski, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)