So ermitteln Sie, ob der Netzwerktyp 2G, 3G oder 4G ist
Habe ich eine Anzeige auf meiner Anwendung zur Anzeige der Netzwerktyp (2G oder 3G oder 4G), aber nachdem ich den Netzwerk-Typ, wie kann ich wissen, was speed-Kategorie es sein sollte?
Ich weiß, wie zu erkennen, die Netzwerk-Typ:
private TelephonyManager telephonyManager;
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
CurrentNetworkType = telephonyManager.getNetworkType();
Angesichts der möglichen Rückgabewerte:
// public static final int NETWORK_TYPE_1xRTT
// Since: API Level 4
// Current network is 1xRTT
// Constant Value: 7 (0x00000007)
//
// public static final int NETWORK_TYPE_CDMA
// Since: API Level 4
// Current network is CDMA: Either IS95A or IS95B
// Constant Value: 4 (0x00000004)
//
// public static final int NETWORK_TYPE_EDGE
// Since: API Level 1
// Current network is EDGE
// Constant Value: 2 (0x00000002)
//
// public static final int NETWORK_TYPE_EHRPD
// Since: API Level 11
// Current network is eHRPD
// Constant Value: 14 (0x0000000e)
//
// public static final int NETWORK_TYPE_EVDO_0
// Since: API Level 4
// Current network is EVDO revision 0
// Constant Value: 5 (0x00000005)
//
// public static final int NETWORK_TYPE_EVDO_A
// Since: API Level 4
// Current network is EVDO revision A
// Constant Value: 6 (0x00000006)
//
// public static final int NETWORK_TYPE_EVDO_B
// Since: API Level 9
// Current network is EVDO revision B
// Constant Value: 12 (0x0000000c)
//
// public static final int NETWORK_TYPE_GPRS
// Since: API Level 1
// Current network is GPRS
// Constant Value: 1 (0x00000001)
//
// public static final int NETWORK_TYPE_HSDPA
// Since: API Level 5
// Current network is HSDPA
// Constant Value: 8 (0x00000008)
//
// public static final int NETWORK_TYPE_HSPA
// Since: API Level 5
// Current network is HSPA
// Constant Value: 10 (0x0000000a)
//
// public static final int NETWORK_TYPE_HSPAP
// Since: API Level 13
// Current network is HSPA+
// Constant Value: 15 (0x0000000f)
//
// public static final int NETWORK_TYPE_HSUPA
// Since: API Level 5
// Current network is HSUPA
// Constant Value: 9 (0x00000009)
//
// public static final int NETWORK_TYPE_IDEN
// Since: API Level 8
// Current network is iDen
// Constant Value: 11 (0x0000000b)
//
// public static final int NETWORK_TYPE_LTE
// Since: API Level 11
// Current network is LTE
// Constant Value: 13 (0x0000000d)
//
// public static final int NETWORK_TYPE_UMTS
// Since: API Level 1
// Current network is UMTS
// Constant Value: 3 (0x00000003)
//
// public static final int NETWORK_TYPE_UNKNOWN
// Since: API Level 1
// Network type is unknown
// Constant Value: 0 (0x00000000)
Ich würde LTE zu 4G, aber welche davon sind wirklich als 3G?
Alles, was ich denken würde, 2G.
Also wo ziehst du die Grenze zwischen 3G oder nicht 3G?
Update:
Ich fand eine andere relevante Antwort auf https://stackoverflow.com/a/8548926/949577
Es nutzt ConnectivityManager() auf, um Typ und Subtyp und dann der Subtyp klassifiziert als entweder schnell oder nicht.
Ich weiß nicht, ob mittels ConnectivityManager() ist der bessere Ansatz ist, dann mit TelephonyManager (), da Sie beide scheinen in der Lage, nach den Netzwerk-Typ.
Außerdem fand ich einen link, der vergleicht wireless-data-standards bei http://en.wikipedia.org/wiki/Comparison_of_wireless_data_standards.
InformationsquelleAutor der Frage Tary | 2012-02-14
Du musst angemeldet sein, um einen Kommentar abzugeben.
Können Sie diese stellen folgende Methode direkt in Ihre Utility-Klasse:
Dank der Hilfe aus dem Android-Quellcode. =]
InformationsquelleAutor der Antwort Anonsage
Basiert auf der Android-Developer-Dokument & Wikipedia-link hier habe ich Kommentare & define Netzwerk-Typ.Überprüfen Sie die links im Kommentar.
Können Sie
getNetworkType
um Netzwerk-Typ.InformationsquelleAutor der Antwort user1140237
Können Sie
getSubtype()
für mehr details.InformationsquelleAutor der Antwort iSun
Technisch gesehen 1xRTT ist ein 3G-Technologie (obwohl viele halten es für 2G basiert ausschließlich auf den Daten-Geschwindigkeit). Auch die Sie hinzufügen möchten, WiMax, um Ihre switch-Anweisung return-4G. Es ist nicht oft benutzt mehr, aber die Sprint-WiMax-Netzwerk ist immer noch in Betrieb.
InformationsquelleAutor der Antwort Omega142
Ich glaube wirklich, Sie müssen nur fest die äquivalente Wert, den Sie wollen, um Sie zu haben. Eine schnelle googeln der meisten dieser Technologien sollte Ihnen einige Weise eine Idee davon, was als 3G oder 4G (obwohl technisch keiner von Ihnen sind echte 4G). Da scheint es nicht zu sein, eine Unterscheidung zwischen HSPA und HSPA+, die Sie möglicherweise ausführen möchten, irgendeine Art von Geschwindigkeit oder Latenz zu überprüfen, und gehen Sie mit das es so ist.
InformationsquelleAutor der Antwort cost