How to determine the mobile operator for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

When you create a Windows Phone app, you might want to know the mobile operator of the user’s phone. You can determine the mobile operator by using the CellularMobileOperator property of the DeviceNetworkInformation class. Because the property is static, you do not have to create an instance of the class first; you can just access the property directly.

Determining the Mobile Operator

In the following procedure, you put the code in a button click event for testing purposes only. In your own applications, you can access the CellularMobileOperator property wherever you need it. The following procedure assumes that you have a Windows Phone application that has a page with a button named button1.

To determine the mobile operator

  1. At the top of the code-behind file for your page, add the following statement.

    using Microsoft.Phone.Net.NetworkInformation;
    
    Imports Microsoft.Phone.Net.NetworkInformation
    
  2. Add the following code to your button click event.

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
    
        sb.Append("Mobile operator:  ");
        sb.AppendLine(DeviceNetworkInformation.CellularMobileOperator);
    
        MessageBox.Show(sb.ToString());
    }
    
    Private Sub Button1_Click(sender As System.Object , e As System.Windows.RoutedEventArgs) Handles Button1.Click
    
        Dim sb As new System.Text.StringBuilder()
    
        sb.Append("Mobile operator:  ")
        sb.AppendLine(DeviceNetworkInformation.CellularMobileOperator)
    
        MessageBox.Show(sb.ToString())
    End Sub
    
  3. Save and build your solution.

  4. Start your application and click the button.

    The message box should appear and your output should look like the following.

    Mobile operator: Fake GSM Network

Note

Fake GSM Network is the information returned by Windows Phone Emulator.

See Also

Reference

DeviceNetworkInformation

System.Net.Sockets

Other Resources

How to get network information for Windows Phone 8

Sockets for Windows Phone 8

Network and network interface information for Windows Phone 8