F5 Debug…

Building & Debugging the Technology!!!

Archive for the ‘Windows Phone 7’ Category

Win Phone 7

101 How to on Windows Phone – How to #33 – Get Mobile Operator details in Windows Phone

Posted by Karthikeyan Anbarasan on May 24, 2012

 

In this tutorial we are going to see how we can get the mobile operator details in Windows Phone Application development. In order to get the mobile operator information we are going to use the API class which is DeviceNetworkInformation class. This class has information on the network details of the specific device from which its called. Since this class is static we can directly make use of this class without creating any instance of the same, by using some of the properties that are available by default.

DeviceNetworkInformation Class has some list of properties by default using which we can collect the information of the specified device which will be very used for system monitoring. Below is the list of properties that can be used to get the details

S No Property Name Property Description
1 CellularMobileOperator Fetches the Mobile Operator name
2 IsCellularDataEnabled Checks if the Mobile operator with a value on Data enabled
3 IsCellularDataRoamingEnabled Checks if the Mobile Operator network allows roaming or not
4 IsNetworkAvailable Checks if the network is available or not
5 IsWiFiEnabled Checks if the Wifi is enabled or not over the network.

So we are going to make use of these properties to check the availability of the network and play around with the properties one by one. To start with Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to show the details of the network operations as shown in the screen below.

SNAGHTML464d69e

Now drag and drop few controls to the screen which are used to get the details of the network operator and other stuffs. Once we designed the screen to show the desired result our screen looks like below.

image

Now we need to write our code behind which basically takes the DeviceNetworkInformation class to get the required details one by one as shown in the code below. Before that we need to add the below using statement in order to make use of the DeviceNetworkInformation class properties.

using Microsoft.Phone.Net.NetworkInformation;

Now add the below code sample which just calls the DeviceNetworkInformation class (we are not creating an instance of the class as its static) with the properties as shown in the code below.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Net.NetworkInformation;

namespace F5debugHowto33
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            textBlock1.Text = "Mobile Operator :- " + DeviceNetworkInformation.CellularMobileOperator.ToString();
            textBlock2.Text = "Network Available :- " + DeviceNetworkInformation.IsNetworkAvailable.ToString();
            textBlock3.Text = "Roaming Available :- " + DeviceNetworkInformation.IsCellularDataRoamingEnabled.ToString();
            textBlock4.Text = "Wifi Available :- " + DeviceNetworkInformation.IsWiFiEnabled.ToString();
            textBlock5.Text = "Cellular Data Available :- " + DeviceNetworkInformation.IsCellularDataEnabled.ToString();
        }
    }
}

 

image

These are the basic properties which can be used in such a way to gather the information of the network mobile operator, say for example when there is a change in the operator and some notification need to be handled. In those cases we can use the NetworkAvailabilityChanged event to see if there is any change in the network operator.

Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.

Output Screens:

image

So we have seen how to get the mobile operator details and the network details using the DeviceNetworkInformation class and also we have seen the event that is used to notify when there is any change in the network operator or the mobile operator. That’s it from this tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

Posted in Windows Phone 7 | Tagged: , , , , | Leave a Comment »

101 How to on Windows Phone – How to #32 – Use Application Deployment Tool in Windows Phone

Posted by Karthikeyan Anbarasan on May 23, 2012

 

In this tutorial we are going to see how to use the Application Deployment tool with Windows Phone Application Development. With this tool we can deploy our application to test it with the registered windows phone device or as well with the Windows Emulators in 512MB ram emulator and also with a 256MB ram emulator. This tool is mainly used to test the application which we develop on to the Emulators and also with the real device which is registered before deploying it to the market place which can avoid the certification failure while deploying the application to the market place.

Application deployment tool is installed by default while we install the Windows Phone SDK on to the development machine and it will be available in one of the following paths as per the installation on to the respective servers.

  • Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\XAP Deployment
  • Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\XAP Deployment

image

We can use this application deployment tool to load upto 10 application on to the registered developers device which basically will not reduce the installed application performances. If we are going to deploy the application on to the device then we need to have a registered Zune account which basically will start the Zune Client. Now let us use this tool to deploy the application which we developed to the emulators instead of the real device, in future we will see how to deploy it to the device. Navigate to the respective path and open the application deployment tool which looks like below.

SNAGHTML3b6062d

If we can see we can select the Target which is basically where our application need to be deployed. If we select the combo box we can see different options like Windows Phone Device, Windows Phone Emulator – 512MB Ram and Windows Phone Emulator – 256 MB Ram as shown in the screen below.

SNAGHTML3b76918

Since we are going to deploy our application to the Emulator we will select the Windows Phone Emulator – 512 MB option and next is to take the packaged application (basically the .XAP file) which will be generated once we are done with the application with building and executing. We can find the developed applications .XAP file in the bin folder as shown in the screen below.

image

Now we are done with selecting the required options and we can see the screen looks like below. Click on Deploy to proceed further which deploys the application to the Emulator.

SNAGHTML3bb361e

Clicking on Deploy will open the Windows Phone Emulator and we can see the application as well as the status of the deployment one by one as shown in the screen’s below.

SNAGHTML3bc2919SNAGHTML3bc6547image

So we are done with our deployment, now we are good to go to test the application completely on this instance of the Windows Phone Emulator. Similarly we can change the emulator target the 256 MB ram device as well and test it completely. That’s it from this tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

Posted in Windows Phone 7 | Tagged: , , , , , , , , , , , , | Leave a Comment »

101 How to on Windows Phone – How to #31 – Test developed applications in both 512MB Ram and 256MB Ram Emulators in Windows Phone

Posted by Karthikeyan Anbarasan on May 22, 2012

 

In this tutorial we are going to see how to test the windows phone application developed in both 512MB ram targeted devices and also 256MB ram devices. This feature is available with the latest Windows Phone SDK 7.1.1, download and install the package using the link Windows Phone SDK 7.1.1 Update. With this update, you can more easily develop apps and games that are optimized to run on 256-MB devices. This update also includes a new 256-MB version of Windows Phone Emulator, an updated 512-MB version of Windows Phone Emulator, and IntelliSense support. Let us see how we test the applications in both the versions of the emulator one by one.

Open Visual Studio 2010 and open any application which we developed with our earlier articles as shown in the screen below.

SNAGHTML2d2793f

Let us consider that the SDK 7.1.1 is already installed and the application is developed, now first let us target the 512 MB ram emulator. We can see the option to select the 512MB ram at the top tool bar as highlighted in the screen below.

image

Once the Windows Phone Emulator – 512 MB option is selected we can able to test our application which will be targeting the 512 MB ram devices. Now simply run the application by pressing F5 and we can see the application opened in the emulator as shown in the screen below.

512 MB Ram Emulator

image

We can see Background tasks are available with the 512 MB ram Windows Phone Emulator with the same options available in the real devices as well. Now we can see in the 256 MB ram the background tasks are not available. To target the 256 Mb ram emulator, just change the emulator type in the top menu tool bar as shown in the screen previously. Once the the option is changed to 256 MB ram build and execute the project and we can see the expected outputs as shown in the screens below.

image

So in this tutorial we have seen how to change the Emulator settings which supports 512 MB ram devices as well on to the 256 MB ram devices with ease which in 256 MB ram the background processing is not supported.

Posted in Windows Phone 7 | Tagged: , , , , , , , , , | Leave a Comment »

101 How to on Windows Phone – How to #30 – Create a Splash Screen in Windows Phone

Posted by Karthikeyan Anbarasan on May 21, 2012

 

In this short tutorial we are going to see how to Create a Splash screen in Windows Phone 7 application development. Splash Screens are nothing but a nice animation or an image shown while an application or a game is loading background. Splash screen provides the user with real effect on how the application will look like. Internally if we can see, Splash screens are mainly used when a large application take some time to collect all the resources to load it completely which the splash screen shows the image in full screen. Today we are going to see how we are going to create a splash screen for Windows Phone 7 application.

Splash screen should follow some basic criteria in Windows Phone application development as below.

  • The image should be of 480 x 800 pixels only
  • The image should be of named Splashscreenimage.jpg only.
  • The Build Property of this Splash Screen file should be Content always.

We can use a static image as a Splash Screen or as well we can use an Animated image but with some things like creating a background processor and other stuffs which should not overwhelm the application performance. Now let us see how we can create one splash screen for our windows phone 7 application. Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below.

SNAGHTML1d8ace2

Now let us create a splash screen using paint or a image editor tool of your choice but keep in consideration that the splash screen should be of the desired points that are recommended by Microsoft. If its failed then our application will be failed in the Certification process which normally will be done while uploading the application to Marketplace. Our Splash screen which we designed looks like below.

image

Now add the splash screen to the project with the name as shown in the screen below and We can customize it as per the requirement.

image

Now we are done with the changes, basically added the splash screen as per our design requirement.  Run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.

Output Screens:

image

So in this tutorial we have seen how to change the splash screen and the basic requirements that are to be considered before changing the splash screen. Also we can add animated splash screen using the background worker processor. That’s it from this tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

Posted in Windows Phone 7 | Tagged: , , , , , , , | Leave a Comment »