Tôi có chỉ báo trên ứng dụng của mình để hiển thị loại mạng (2G hoặc 3G hoặc 4G) nhưng sau khi nhận được loại mạng, làm cách nào để biết loại tốc độ nào ở trong?Cách xác định xem loại mạng là 2G, 3G hoặc 4G
tôi biết làm thế nào để phát hiện các loại mạng:
private TelephonyManager telephonyManager;
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
CurrentNetworkType = telephonyManager.getNetworkType();
Với giá trị trả về có thể:
// 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)
tôi sẽ xem xét LTE là 4G, nhưng mà trong số này đang thực sự coi 3G? Bất cứ điều gì khác tôi sẽ xem xét 2G.
Vậy bạn sẽ vẽ đường dây giữa 3G hoặc 3G ở đâu?
Cập nhật: Tôi tìm thấy câu trả lời có liên quan khác tại https://stackoverflow.com/a/8548926/949577 Sử dụng ConnectivityManager() để nhận loại và loại phụ rồi phân loại loại phụ nhanh hay không. Tôi không biết nếu sử dụng ConnectivityManager() là một cách tiếp cận tốt hơn sau đó sử dụng TelephonyManager() vì cả hai đều xuất hiện có thể trả về loại mạng.
Ngoài ra tôi tìm thấy một liên kết so sánh các tiêu chuẩn dữ liệu không dây tại http://en.wikipedia.org/wiki/Comparison_of_wireless_data_standards.
có thể trùng lặp của [Phát hiện loại kết nối mạng trên Android] (http://stackoverflow.com/questions/2802472/detect-network-connection-type-on-android) – ben75