用户登录
用户注册

分享至

Android 判断当前网络是5G

  • 作者: frivol
  • 来源: 51数据库
  • 2021-09-21

Google??TelephonyManager类提供了对应的方法

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            int networkType = telephonyManager.getNetworkType();
            // 这里对应的值为20 只有依赖为android 10.0才有此属性 
            if(networkType ==TelephonyManager.NETWORK_TYPE_NR){
            	Log.i(TAG,"5G");
            }

google官方说明为:
地址为:https://developer.android.com/reference/android/telephony/TelephonyManager

int	NETWORK_TYPE_NR
Current network is NR(New Radio) 5G.
NETWORK_TYPE_NR
Added in API level 29
public static final int NETWORK_TYPE_NR
Current network is NR(New Radio) 5G.

Constant Value: 20 (0x00000014)

?

软件
前端设计
程序设计
Java相关