locked
Is this method reliable to detect mobile connection (2G/3G/4G) RRS feed

  • Question

  • I need to detect Mobile connection. Understand now Nokia's tablet is LTE based ( or 3G?) or Any tablet with 3G or 4G capability.

    I use below code to detect the Connection and IANA definition to identify the connection type

    http://www.iana.org/assignments/ianaiftype-mib/ianaiftype-mib

    wwanPP (243), -- 3GPP WWAN
    wwanPP2 (244), -- 3GPP2 WWAN

    The problem:

    1) When I test it in Emulator in Wifi and Cable connection to internet on the PC, the result always show Internet connection even the PC connected to WiFi.

    2) Can I use the IANA code to identify mobile Network (3G or 4G)?

    var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

                var interfaceType = profile.NetworkAdapter.IanaInterfaceType;

                // 71 is WiFi & 6 is Ethernet

                if (interfaceType == 71 )
                {

                    var MyMessageBox = new Windows.UI.Popups.MessageDialog("wifi :", "wifi Connection");
                    await MyMessageBox.ShowAsync();

                   
                }
                else if(interfaceType == 6)
                {
                    var MyMessageBox = new Windows.UI.Popups.MessageDialog("Internet :", "Internet

    Connection");
                    await MyMessageBox.ShowAsync();
               
                } //3G/Mobile Detect
                else if (interfaceType == 243 | interfaceType == 244)
                {
                 
                    var MyMessageBox = new Windows.UI.Popups.MessageDialog("Mobile Connection :", "Mobile

    Connection");
                    await MyMessageBox.ShowAsync();

                }
                else
                {
                    var MyMessageBox = new Windows.UI.Popups.MessageDialog("Not Mobile or Internet or wifi :",

    "Not Mobile or Internet or wifi Connection");
                    await MyMessageBox.ShowAsync();
                }

     Thanks

     

     

     

    Wednesday, December 11, 2013 7:35 AM

All replies

  • Can you explain why you care about how you're getting your internet connectivity?  That is, what will you do or not do as a result?

    I know that in the past, people have felt that "WiFi is fast" or "3G is expensive" -- but really, that's not true any more at all.  For each connectivity type, there are situations where it's the fastest, and places it's the slowest; places it's the most open, and places it's the least open.  And the same goes for price.

    And price you should get through the normal mechanisms, not the IANA types.

    (And, BTW, you have a bug in your program: you are incorrectly reporting Ethernet to be 'internet')


    Network Developer Experience Team (Microsoft)

    Wednesday, December 11, 2013 9:07 PM
  • Hi,

    I am developing an enterprise mobile sales for companies which have mobile sales force to do online and offline transaction base on Microsoft Dynamics Navision.

    The reason(s) of using this detection is :

    1.  I need to know if there is internet or mobile (3G/4G)connection when the mobile sales personnel using my App to do transaction at customer's side.

    Condition(s):

    a)If there is no internet connection ( Types : WiFi or 3G/4G), the App will turn on Offline mode transaction. This means my App will NOT communicate with Ms Dynamics Navision (or AX) in real time or online thru web services.

    b) If there is internet connection, my app will turn on Online Mode Transaction which will communication with Ms Dynamics NAV in real time or online thru webservices

    I need help as this method does not seems to work!  I tested in this conditions:

    1) tested in Emulator, disconnect WiFi as well as disconnect Ethernet cable to the LapTop running Win8 pro.

    the result : Ethernet connection.  Why ? This should not be.

    2) tested in Emulator, connect WiFi  and disconnect Ethernet-cable  to this Laptop.

    the result : Ehternet connection.  

    Would appreciate your help.

    Thanks


    • Edited by FireDance Thursday, December 12, 2013 1:14 AM typo
    Thursday, December 12, 2013 1:11 AM