原文地址 http://blog.sina.com.cn/s/blog_4a9f789a0100m5vn.html
这里需要说明的是国内手机是查看不到手机号的
本人比较倾向于使用
String regPhoneInfo = android.os.Build.PRODUCT;
可以获取到系统的版本以及手机的型号等,比较方便,不用一个一个的单独来获取。
- <!-- 联网权限 -->
- <uses-permission
- android:name="android.permission.INTERNET" />
- <!-- 获取机型信息权限 -->
- <uses-permission
- android:name="android.permission.READ_PHONE_STATE" />
- <!-- 获取短信发送权限 -->
- <uses-permission
- android:name="android.permission.SEND_SMS" />
package com.mc;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.TextView;
public class TelManager extends Activity {
TextView textView01 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView01 = (TextView) this.findViewById(R.id.textView01);
// getPhoneNumber();
fetch_status();
System.out.println("-------------------onCreate");
}
public void getPhoneNumber() {
// 获取手机号、手机串号信息
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imei = tm.getDeviceId();//获取的是手机串号
String tel = tm.getLine1Number();
textView01.setText("手机串号:" + imei + "n" + "手机号:" + tel + "n");
}
public void fetch_status() {
TelephonyManager tm = (TelephonyManager) this
.getSystemService(Context.TELEPHONY_SERVICE);//
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()
+ "n";
str += "Line1Number = " + tm.getLine1Number() + "n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "n";
str += "NetworkType = " + tm.getNetworkType() + "n";
str += "honeType = " + tm.getPhoneType() + "n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "n";
str += "SimOperator = " + tm.getSimOperator() + "n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "n";
str += "SimState = " + tm.getSimState() + "n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "n";
textView01.setText(str);
}
}
在Android中以上机型信息在手机状态Status里
Settings->About Phone->Status
各个栏目的功能介绍如下:
Battery status:电池充电/未充电状态
Battery level:电池剩余电量
Phone number:手机序列号
Network:所处的移动网络
Signal strength:信号度
Network type:网络制式
Service state:所在服务区
Roaming:漫游/未漫游
Data access:共访问的数据大小
IMEI:IMEI码
IMEI SV:IMEI码的版本
IMSI:国际移动用户识别码
Wi-Fi Mac address:G1无线Wi-Fi网络的Mac地址。
Bluetooth address:蓝牙地址
Up time:正常运行时间
Awake Time:手机唤醒时间