客户端获取收集信息
package com.img.test01; import android.app.Activity; import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.provider.Settings.Secure; import android.telephony.TelephonyManager; /** * 注意:在调用的时候,必须首先添加相对应的权限,谢谢 * <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> * <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> * <uses-permission android:name="android.permission.READ_PHONE_STATE" /> * @author Administrator * */ public class DeviceMessage { public Activity activity; TelephonyManager tm; public DeviceMessage(Activity activity) { super(); this.activity = activity; tm = (TelephonyManager) activity .getSystemService(activity.TELEPHONY_SERVICE); } /** * 获取手机号码 */ public String GetTelephone() { String TEL = tm.getLine1Number();// 手机号 return TEL; } /** * 获取手机IMSI信息 */ public String GetIMSI() { String IMSI = tm.getSubscriberId();// 国际移动用户识别码,是区别移动用户的标 return IMSI; } /** * 获取手机IMEI信息 */ public String GetIMEI() { String IMEI = tm.getDeviceId();// 国际移动用户识别码,是区别移动用户的标 return IMEI; } /** * 通过wifi获取Ip地址 * * @return */ public String GetWiFi() { // 获取wifi服务 WifiManager wifiManager = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE); // 判断wifi是否开启 if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); } WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); String ip = intToIp(ipAddress); return ip; } private String intToIp(int i) { return (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + (i >> 24 & 0xFF); } /** * 系统唯一的id * * @return */ public String getDeviceId() { String android_id = Secure.getString(activity.getContentResolver(), Secure.ANDROID_ID); return android_id; } } String SIM = tm.getSimSerialNumber();// 获取手机序列号 String version = tm.getDeviceSoftwareVersion();// 设备的软件版本号 int PhoneType = tm.getPhoneType();// 手机类型 String CountryIso = tm.getSimCountryIso();// 获取ISO国家码,相当于提供SIM卡的国家码
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28