文章目录
  1. 1. 判断网线是否ok

判断网线是否ok

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* 有线网络是否插入
* @return
*/
private boolean isWirePluggedIn() {
try {
File file = new File("/sys/class/net/eth0/carrier");

BufferedReader reader = new BufferedReader(new FileReader(file));
String carrier = reader.readLine();
if (!TextUtils.isEmpty(carrier)) {
int carrier_state = Integer.parseInt(carrier);
return carrier_state == 1;
}

} catch (Exception e) {
e.printStackTrace();
return false;
}
return false;
}

参考文章:Android/Linux检测网线是否插入

文章目录
  1. 1. 判断网线是否ok