DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

How-To: Get Mobile Operator details in Windows Phone

Karthikeyan Anbarasan user avatar by
Karthikeyan Anbarasan
·
May. 27, 12 · Interview
Like (0)
Save
Tweet
Share
6.69K Views

Join the DZone community and get the full member experience.

Join For Free

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

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!!!s

Windows Phone Operator (extension) mobile app

Published at DZone with permission of Karthikeyan Anbarasan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Reliability Is Slowing You Down
  • gRPC on the Client Side
  • Testing Level Dynamics: Achieving Confidence From Testing
  • 11 Observability Tools You Should Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: