Floating FB popout byF5debug

Programmatically get Mobile Operator Information and Settings in Windows Phone

 

In this short tutorial you are going to see how to programmatically query and get the mobile Operator information and settings that are applicable. This feature is pretty much needed in any application that uses internet when to check if the Internet connection is active and if active then need to check if the data is coming from Wifi or service provider and from which service provider and to check if the service provider is local provider or in roaming etc. So with these use cases this feature can be more useful in checking the options that the device is current using to avoid any additional charges.

Ok now the next question is which API provides these information, in Windows Phone SDK we have the DeviceNetworkInformation class provides the information about the Device specific and network specific properties. This class is much more used in all the test cases that we discussed above. With this class there are couple of properties like below which can be utilized to check the Mobile Operator and information about the settings in Windows Phone.

  • CellularMobileOperator – This property checks the current service provider information of the operator to which the device is mapped
  • IsCellularDataRomingEnabled – This property has the status of the setting which will tell if the operator assigned is in Roaming or Local provider.

Code:

private void Button_Click(object sender, RoutedEventArgs e)
        {
            var MobileOperatorInfo = DeviceNetworkInformation.CellularMobileOperator;
            txtMobOp.Text = MobileOperatorInfo.ToString();

            if (DeviceNetworkInformation.IsCellularDataRoamingEnabled)
            {
                var Status = "Data Roaming enabled.";
                txtRoam.Text = Status.ToString();
            }
            else
            {
                var Status = "Data Roaming not enabled.";
                txtRoam.Text = Status.ToString();
            }

        }

 

image

The above code is a very basic operation before we does check the network information if the internet is active or not and to check if the internet is connected to Wifi or Mobile operators etc. These operations are to be checked in real time before you check for the mobile operator which gives you more flexibility in assigning the appropriate setting to the application.

 

image

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter