TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return “”;
}
return “” + tm.getNetworkOperatorName();
}
//sim卡序列号
public static String getSimSerialNumber(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return “”;
}
return “” + tm.getSimSerialNumber();
}
//IMSI
public static String getSubscriberId(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return “”;
}
return “” + tm.getSubscriberId();
}
//sim卡所在国家
public static String getNetworkCountryIso(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return “”;
}
return “” + tm.getNetworkCountryIso();
}
//运营商编号。
public static String getNetworkOperator(Context context) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null) {
return “”;
}
return tm.getNetworkOperator();
}
//android 获取当前手机型号
public static String getPhoneModel(Context context) {
Build bd = new Build();
return bd.MODEL;
}
//android 获取当前手机品牌
public static String getPhoneProduct(Context context) {
Build bd = new Build();
return bd.PRODUCT;
}
//android 获取屏幕分辩率
public static String getMetrics(Context context) {
DisplayMetrics dm = new DisplayMetrics();
int h = dm.heightPixels;
int w = dm.widthPixels;
return h+ “*” +w;
}
//android获取当前时区
public static String getTimeZone(Context context) {
TimeZone tz = TimeZone.getDefault();
String s = tz.getID();
System.out.println(s);
return s;
}
//android获取当前日期时间
public static String getDateAndTime(Context context) {
SimpleDateFormat formatter = new SimpleDateFormat (“yyyy-MM-dd HH:mm:ss”);
Date curDate = new Date(System.currentTimeMillis());//获取当前时间
String str = formatter.format(curDate);
return str;
}
//获取手机系统语言 0中文简体 1其它
public static String getLanguage(Context context) {
Locale locale = context.getResources().getConfiguration().locale;
String language = locale.getLanguage();
if (language.endsWith(“zh”))
return “0”;
else
return “1”;
}
/**
- 获取网络类型
*/
public static int getNetWorkType(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = manager.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
String type = networkInfo.getTypeName();
if (type.equalsIgnoreCase(“WIFI”)) {
return AVConstants.NETTYPE_WIFI;
} else if (type.equalsIgnoreCase(“MOBILE”)) {
NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (mobileInfo != null) {
switch (mobileInfo.getType()) {
case ConnectivityManager.TYPE_MOBILE:// 手机网络
switch (mobileInfo.getSubtype()) {
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_EVDO_0:
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_EVDO_B:
case TelephonyManager.NETWORK_TYPE_EHRPD:
case TelephonyManager.NETWORK_TYPE_HSPAP:
return AVConstants.NETTYPE_3G;
case TelephonyManager.NETWORK_TYPE_CDMA:
最后
在这里我和身边一些朋友特意整理了一份快速进阶为Android高级工程师的系统且全面的学习资料。涵盖了Android初级——Android高级架构师进阶必备的一些学习技能。
附上:我们之前因为秋招收集的二十套一二线互联网公司Android面试真题(含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!
AT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)
[外链图片转存中…(img-exWrnady-1714453761083)]
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!