您的位置:首页 > 移动开发 > Android开发

Android获取硬件设备信息

2017-06-03 23:34 411 查看
此文介绍一些获取Android手机硬件信息的方法 主要是从Build和TelephonyManager中获取 以及使用反射获取SystemProperties

并使用他的get方法获取一些系统隐藏掉的API 以及某些ROM独有的数据 比如OPPO手机自己定制的osVersion ColorOS版本 OPPO手机ROM特有

分别获取了以下内容

列表内容

名称接口参数名称备注示例
序列号getDeviceId序列号IMEI865872025238821
andrlid_idgetStringandroid_idbcbc00f09479aa5b
手机号码getLine1Number手机号码13117511178
手机卡序列号getSimSerialNumber手机卡序列号89860179328595969501
IMSIgetSubscriberIdIMSI460017932859596
手机卡国家getSimCountryIso手机卡国家cn
运营商getSimOperator运营商46001
运营商名字getSimOperatorName运营商名字中国联通
国家iso代码getNetworkCountryIso国家iso代码cn
网络运营商类型getNetworkOperator返回MCC+MNC代码(SIM卡运营商国家代码和运营商网络代码)(IMSI) 46001
网络类型名getNetworkOperatorName返回移动网络运营商的名字(SPN)中国联通
网络类型getNetworkType3
手机类型getPhoneType手机类型1
手机卡状态getSimState1
mac地址getMacAddressmac地址a8:a6:68:a3:d9:ef
蓝牙名称getNameHUAWEI TAG-TL00
返回系统版本getDeviceSoftwareVersionnull
CPU型号cpuinfoCPU的型号MT6592
固件版本getRadioVersion无线电固件版本号,通常是不可用的MOLY.WR8.W1328.MD.TG.MP.V1.P22, 2014/07/15 19:57
Build系列android.os.Build
系统版本RELEASE获取系统版本字符串。如4.1.2 或2.2 或2.3等4.4.4
系统版本值SDK系统的API级别 一般使用下面大的SDK_INT 来查看19
品牌BRAND获取设备品牌Huawei
型号MODEL获取手机的型号HUAWEI G750-T01
IDID设备版本号HUAWEITAG-TLOO
DISPLAYDISPLAY获取设备显示的版本包(在系统设置中显示为版本号)和ID一样TAG-TLOOCO1B166
产品名PRODUCT整个产品的名称G750-T01
制造商MANUFACTURER获取设备制造商HUAWEI
设备名DEVICE获取设备驱动名称hwG750-T01
硬件HARDWARE设备硬件名称,一般和基板名称一样(BOARD)mt6592
指纹FINGERPRINT设备的唯一标识。由设备的多个信息拼接合成Huawei/G750-T01/hwG750-T01:4.2.2/HuaweiG750-T01/C00B152:user/ota-rel-keys,release-keys
串口序列号SERIAL返回串口序列号YGKBBBB5C1711949
设备版本类型TYPE主要为user 或eng.user
描述build的标签TAGS设备标签。如release-keys 或测试的 test-keysrelease-keys
设备主机地址HOST设备主机地址scmbuild
设备用户名USER基本上都为android-buildqueen
固件开发版本代号codename设备当前的系统开发代号,一般使用REL代替REL
源码控制版本号build_incremental系统源代码控制值,一个数字或者git hash值C01B166
主板board获取设备基板名称TAG-TL00
主板引导程序bootloader获取设备引导程序版本号unkonwn
Build时间timeBuild时间1476084456000
系统的API级别SDK_INT数字表示19
cpu指令集1CPU_ABI获取设备指令集名称(CPU的类型)arm64-v8a
cpu指令集2CPU_ABI2
WifiManagerWIFI相关
蓝牙地址getAddress蓝牙地址MAC地址6a:cd:57:f2:3b:59
无线路由器名getSSIDWIFI名字210e03fcf0
无线路由器地址getBSSIDce:ea:8c:1a:5c:b2
内网ip(wifl可用)getIpAddress可以用代码转成192.168形式-2023511872
Display屏幕相关
屏幕密度density屏幕密度(像素比例:0.75/1.0/1.5/2.0)2.0
屏幕密度densityDpi屏幕密度(每寸像素:120/160/240/320)480
手机内置分辨率getWidth内置好的不准确已废弃API720
手机内置分辨率getHeight1184
x像素xdpi屏幕x方向每英寸像素点数422.03
Y像素ydpi屏幕y方向每英寸像素点数424.069
字体缩放比例scaledDensity2.0

代码

写的很烂 早期作品 千万不要喷我啊

private TelephonyManager phone;
private WifiManager wifi;
private Display display;
private DisplayMetrics metrics;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

phone = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
display = getWindowManager().getDefaultDisplay();

metrics = getResources().getDisplayMetrics();

init();
}

private void init() {
DisplayMetrics book=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(book);

try {
Class localClass = Class.forName("android.os.SystemProperties");
Object localObject1 = localClass.newInstance();
Object localObject2 = localClass.getMethod("get", new Class[] { String.class, String.class }).invoke(localObject1, new Object[] { "gsm.version.baseband", "no message" });
Object localObject3 = localClass.getMethod("get", new Class[] { String.class, String.class }).invoke(localObject1, new Object[] { "ro.build.display.id",""});

setEditText(R.id.get,localObject2+"");

setEditText(R.id.osVersion,localObject3+"");
} catch (Exception e) {
e.printStackTrace();
}

//获取网络连接管理者
ConnectivityManager connectionManager = (ConnectivityManager)
getSystemService(CONNECTIVITY_SERVICE);
//获取网络的状态信息,有下面三种方式
NetworkInfo networkInfo = connectionManager.getActiveNetworkInfo();

setEditText(R.id.lianwang,networkInfo.getType()+"");
setEditText(R.id.lianwangname,networkInfo.getTypeName());
setEditText(R.id.imei, phone.getDeviceId());
setEditText(R.id.deviceversion,phone.getDeviceSoftwareVersion());
setEditText(R.id.imsi, phone.getSubscriberId());
setEditText(R.id.number, phone.getLine1Number());
setEditText(R.id.simserial, phone.getSimSerialNumber());
setEditText(R.id.simoperator,phone.getSimOperator());
setEditText(R.id.simoperatorname, phone.getSimOperatorName());
setEditText(R.id.simcountryiso, phone.getSimCountryIso());
setEditText(R.id.workType,phone.getNetworkType()+"");
setEditText(R.id.netcountryiso,phone.getNetworkCountryIso());
setEditText(R.id.netoperator,phone.getNetworkOperator());
setEditText(R.id.netoperatorname,phone.getNetworkOperatorName());

setEditText(R.id.radiovis,android.os.Build.getRadioVersion());
setEditText(R.id.wifimac, wifi.getConnectionInfo().getMacAddress());
setEditText(R.id.getssid,wifi.getConnectionInfo().getSSID());
setEditText(R.id.getbssid,wifi.getConnectionInfo().getBSSID());
setEditText(R.id.ip,wifi.getConnectionInfo().getIpAddress()+"");
setEditText(R.id.bluemac, BluetoothAdapter.getDefaultAdapter()
.getAddress());
setEditText(R.id.bluname, BluetoothAdapter.getDefaultAdapter().getName()
);

setEditText(R.id.cpu,getCpuName());

setEditText(R.id.andrlid_id,
Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
setEditText(R.id.serial,android.os.Build.SERIAL);
setEditText(R.id.brand,android.os.Build.BRAND);
setEditText(R.id.tags, android.os.Build.TAGS);
setEditText(R.id.device,android.os.Build.DEVICE);
setEditText(R.id.fingerprint,android.os.Build.FINGERPRINT);
setEditText(R.id.bootloader, Build.BOOTLOADER);
setEditText(R.id.release, Build.VERSION.RELEASE);
setEditText(R.id.sdk,Build.VERSION.SDK);
setEditText(R.id.sdk_INT,Build.VERSION.SDK_INT+"");
setEditText(R.id.codename,Build.VERSION.CODENAME);
setEditText(R.id.incremental,Build.VERSION.INCREMENTAL);
setEditText(R.id.cpuabi, android.os.Build.CPU_ABI);
setEditText(R.id.cpuabi2, android.os.Build.CPU_ABI2);
setEditText(R.id.board, android.os.Build.BOARD);
setEditText(R.id.model, android.os.Build.MODEL);
setEditText(R.id.product, android.os.Build.PRODUCT);
setEditText(R.id.type, android.os.Build.TYPE);
setEditText(R.id.user, android.os.Build.USER);
setEditText(R.id.disply, android.os.Build.DISPLAY);
setEditText(R.id.hardware, android.os.Build.HARDWARE);
setEditText(R.id.host, android.os.Build.HOST);
setEditText(R.id.changshang, android.os.Build.MANUFACTURER);
setEditText(R.id.phonetype,phone.getPhoneType()+"");
setEditText(R.id.simstate,phone.getSimState()+"");
setEditText(R.id.b_id, Build.ID);
setEditText(R.id.gjtime,android.os.Build.TIME+"");
setEditText(R.id.width,display.getWidth()+"");
setEditText(R.id.height,display.getHeight()+"");
setEditText(R.id.dpi,book.densityDpi+"");
setEditText(R.id.density,book.density+"");
setEditText(R.id.xdpi,book.xdpi+"");
setEditText(R.id.ydpi,book.ydpi+"");
setEditText(R.id.scaledDensity,book.scaledDensity+"");

//setEditText(R.id.wl,getNetworkState(this)+"");
// 方法2
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width=dm.widthPixels;
int  height=dm.heightPixels;

setEditText(R.id.xwidth,width+"");
setEditText(R.id.xheight,height+"");

}

private void setEditText(int id, String s) {
((TextView) this.findViewById(id)).setText(s);
}
/**
* 获取CPU型号
* @return
*/
public static String getCpuName(){

String str1 = "/proc/cpuinfo";
String str2 = "";

try {
FileReader fr = new FileReader(str1);
BufferedReader localBufferedReader = new BufferedReader(fr);
while ((str2=localBufferedReader.readLine()) != null) {
if (str2.contains("Hardware")) {
return str2.split(":")[1];
}
}
localBufferedReader.close();
} catch (IOException e) {
}
return null;

}


XML

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lyq.test.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout style="@style/Item.Layout">

<TextView
android:id="@+id/lianwang"
style="@style/Item.Edit"
android:inputType="number" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="联网方式"
/>

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:id="@+id/lianwangname"
style="@style/Item.Edit"
android:inputType="number" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="联网方式名称"
/>

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:id="@+id/imei"
style="@style/Item.Edit"
android:hint="请输入IMEI"
android:inputType="number" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="IMEI"
/>

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="返回系统版本"/>

<TextView
android:id="@+id/deviceversion"
style="@style/Item.Edit"
android:hint="返回系统版本"
/>

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="IMSI"/>

<TextView
android:id="@+id/imsi"
style="@style/Item.Edit"
android:hint="请输入IMSI"
/>
</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机号码"/>

<TextView
android:id="@+id/number"
style="@style/Item.Edit"
android:hint="请输入手机号码"
/>

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机卡序列号" />

<TextView
android:id="@+id/simserial"
style="@style/Item.Edit"
android:inputType="number" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="运营商" />

<TextView
android:id="@+id/simoperator"
style="@style/Item.Edit"
android:hint="simoperator"
/>

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="运营商名字" />

<TextView
android:id="@+id/simoperatorname"
style="@style/Item.Edit"
android:hint="simoperator"
android:inputType="number" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="国家iso代码" />

<TextView
android:id="@+id/simcountryiso"
style="@style/Item.Edit"
android:hint="请输入"
android:inputType="number" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="网络类型" />

<TextView
android:id="@+id/workType"
style="@style/Item.Edit"
android:hint="网络类型"
android:inputType="number" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机卡国家" />

<TextView
android:id="@+id/netcountryiso"
style="@style/Item.Edit"
android:hint="手机卡国家"
android:inputType="number" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="网络运营商类型" />

<TextView
android:id="@+id/netoperator"
style="@style/Item.Edit"
android:hint="网络运营商类型"
android:inputType="number" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="网络类型名" />

<TextView
android:id="@+id/netoperatorname"
style="@style/Item.Edit"
android:hint="网络类型名"
android:inputType="number" />
</RelativeLayout>

<!--   <RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="网络类型" />

<TextView
android:id="@+id/wl"
style="@style/Item.Edit"
android:hint="网络类型"
android:inputType="number" />
</RelativeLayout>

-->

<RelativeLayout style="@style/Item.Layout" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="固件版本" />

<TextView
android:id="@+id/radiovis"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="mac地址" />

<TextView
android:id="@+id/wifimac"
style="@style/Item.Edit"
android:hint="mac地址" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="无线路由器名" />

<TextView
android:id="@+id/getssid"
style="@style/Item.Edit"
android:hint="无线路由器名" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="无线路由器地址" />

<TextView
android:id="@+id/getbssid"
style="@style/Item.Edit"
android:hint="无线路由器地址" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="蓝牙地址" />

<TextView
android:id="@+id/bluemac"
style="@style/Item.Edit"
android:hint="蓝牙地址" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="蓝牙名称" />

<TextView
android:id="@+id/bluname"
style="@style/Item.Edit"
android:hint="请输入蓝牙name" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="andrlid_id" />

<TextView
android:id="@+id/andrlid_id"
style="@style/Item.Edit"
android:hint="请输入Android ID" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="串口序列号" />

<TextView
android:id="@+id/serial"
style="@style/Item.Edit"
android:hint="串口序列号" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="品牌" />

<TextView
android:id="@+id/brand"
style="@style/Item.Edit"
android:hint="品牌" />

</RelativeLayout>
<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="get" />

<TextView
android:id="@+id/get"
style="@style/Item.Edit"
android:hint="get" />

</RelativeLayout>
<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="osVersion" />

<TextView
android:id="@+id/osVersion"
style="@style/Item.Edit"
android:hint="osVersion" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="描述build的标签" />

<TextView
android:id="@+id/tags"
style="@style/Item.Edit"
android:hint="描述build的标签" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="设备名" />

<TextView
android:id="@+id/device"
style="@style/Item.Edit"
android:hint="设备名" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="主板引导程序" />

<TextView
android:id="@+id/bootloader"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="系统版本" />

<TextView
android:id="@+id/release"
style="@style/Item.Edit"
android:hint="系统版本" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="系统版本值" />

<TextView
android:id="@+id/sdk"
style="@style/Item.Edit"
android:hint="系统版本值" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="系统的API级别" />

<TextView
android:id="@+id/sdk_INT"
style="@style/Item.Edit"
android:hint="系统的API级别" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="固件开发版本代号" />

<TextView
android:id="@+id/codename"
style="@style/Item.Edit"
android:hint="固件开发版本代号" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="源码控制版本号" />

<TextView
android:id="@+id/incremental"
style="@style/Item.Edit"
android:hint="源码控制版本号" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CPU型号" />

<TextView
android:id="@+id/cpu"
style="@style/Item.Edit"
android:hint="CPU型号" />
</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="cpu指令集" />

<TextView
android:id="@+id/cpuabi"
style="@style/Item.Edit"
android:hint="cpu指令集" />
</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="cpu指令集2" />

<TextView
android:id="@+id/cpuabi2"
style="@style/Item.Edit"
android:hint="" />
</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="主板" />

<TextView
android:id="@+id/board"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="型号" />

<TextView
android:id="@+id/model"
style="@style/Item.Edit"
android:hint="请输入型号" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="产品名称" />

<TextView
android:id="@+id/product"
style="@style/Item.Edit"
android:hint="请输入型号" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="设备版本类型" />

<TextView
android:id="@+id/type"
style="@style/Item.Edit"
android:hint="设备版本类型" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="设备用户名" />

<TextView
android:id="@+id/user"
style="@style/Item.Edit"
android:hint="设备用户名" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="显示屏幕参数" />

<TextView
android:id="@+id/disply"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="硬件名称" />

<TextView
android:id="@+id/hardware"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="设备主机地址" />

<TextView
android:id="@+id/host"
style="@style/Item.Edit"
android:hint="设备主机地址" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="制造商" />

<TextView
android:id="@+id/changshang"
style="@style/Item.Edit"
android:hint="制造商" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机类型" />

<TextView
android:id="@+id/phonetype"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机卡状态" />

<TextView
android:id="@+id/simstate"
style="@style/Item.Edit"
android:hint="手机卡状态" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ID" />

<TextView
android:id="@+id/b_id"
style="@style/Item.Edit"
android:hint="ID" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="内网ip" />

<TextView
android:id="@+id/ip"
style="@style/Item.Edit"
android:hint="内网ip" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Build时间" />

<TextView
android:id="@+id/gjtime"
style="@style/Item.Edit"
android:hint="Build时间" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="指纹" />

<TextView
android:id="@+id/fingerprint"
style="@style/Item.Edit"
android:hint="指纹" />

</RelativeLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="           ---------------手机屏幕信息--------------"

/>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机内置 宽" />

<TextView
android:id="@+id/width"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="手机内置 高" />

<TextView
android:id="@+id/height"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="当前分辨率" />

<TextView
android:id="@+id/xwidth"
style="@style/Item.Edit"
android:hint="当前分辨率" />

</RelativeLayout>
<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="当前分辨率" />

<TextView
android:id="@+id/xheight"
style="@style/Item.Edit"
android:hint="当前分辨率" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dpi" />

<TextView
android:id="@+id/dpi"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="density" />

<TextView
android:id="@+id/density"
style="@style/Item.Edit"
android:hint="请输入" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="x像素" />

<TextView
android:id="@+id/xdpi"
style="@style/Item.Edit"
android:hint="x像素" />

</RelativeLayout>

<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Y像素" />

<TextView
android:id="@+id/ydpi"
style="@style/Item.Edit"
android:hint="Y像素" />

</RelativeLayout>
<RelativeLayout style="@style/Item.Layout">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="字体缩放比例" />

<TextView
android:id="@+id/scaledDensity"
style="@style/Item.Edit"
android:hint="字体缩放比例" />

</RelativeLayout>
</LinearLayout>
</ScrollView>


values配置信息

<style name="Item">
<item name="android:textColor">@android:color/black</item>
</style>
<style name="Item.Layout">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">50dip</item>
<item name="android:orientation">vertical</item>
</style>

<style name="Item.Label">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>

</style>

<style name="Item.Edit">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_marginLeft">120dip</item>
<item name="android:layout_marginRight">100dip</item>

</style>


我对某些函数的描述可能不太对 不要喷我哦

还有某些数据会获取不到 尤其手机号码 市面上大部分的SIM卡内置都没有手机号码 所以getLine1Number 根本就取不到

想获取的朋友可以google 百度 一般都是用发短信来实现的

效果图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: