Android 获取手机Mac和IP
来源:互联网 发布:刘永伟 知行路桥 编辑:程序博客网 时间:2024/04/30 00:32
public class MacUtils {
/**
* 获取手机MAC地址。
*
* @param mContext
* @return MAC地址
*/
public static String getMacAddress(Context mContext) {
WifiManager wm = (WifiManager) mContext
.getSystemService(Context.WIFI_SERVICE);
WifiInfo wi = wm.getConnectionInfo();
return wi.getMacAddress();
}
/**
* 获取用户IP地址。
*
* @param mContext
* @return IP地址
*/
public static String getIpAddress(Context mContext) {
WifiManager wm = (WifiManager) mContext
.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wm.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
if (ipAddress == 0)
return "0";
return ((ipAddress & 0xff) + "." + (ipAddress >> 8 & 0xff) + "."
+ (ipAddress >> 16 & 0xff) + "." + (ipAddress >> 24 & 0xff));
}
}
/**
* 获取手机MAC地址。
*
* @param mContext
* @return MAC地址
*/
public static String getMacAddress(Context mContext) {
WifiManager wm = (WifiManager) mContext
.getSystemService(Context.WIFI_SERVICE);
WifiInfo wi = wm.getConnectionInfo();
return wi.getMacAddress();
}
/**
* 获取用户IP地址。
*
* @param mContext
* @return IP地址
*/
public static String getIpAddress(Context mContext) {
WifiManager wm = (WifiManager) mContext
.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wm.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
if (ipAddress == 0)
return "0";
return ((ipAddress & 0xff) + "." + (ipAddress >> 8 & 0xff) + "."
+ (ipAddress >> 16 & 0xff) + "." + (ipAddress >> 24 & 0xff));
}
}
0 0
- Android 获取手机Mac和IP
- Android获取手机地址(Mac、ip和imei)
- Android_获取手机IP和MAC地址
- android 获得手机MAC 和 IP
- Android获取手机及路由器的Mac地址和IP地址
- Android获取手机IP地址 WIFI MAC地址
- android 获取设备IP和Mac地址
- android获取Mac地址和IP地址
- android 获取设备IP和Mac地址
- Android:获取MAC和IP 地址
- android获取Mac地址和IP地址
- Android 获取本机Ip 和 Mac
- Android 获取Mac地址和IP
- Android 获取Mac地址和IP地址
- 获取android手机ip
- android获取手机ip
- android获取手机ip
- android获取手机ip
- 大型网站系统架构演化之路
- 一切成功源于积累——20140928 认识货币——澳元
- c#截取字符串,经过验证的
- 使用TOMCAT5.5连接池连接mysql(解决Cannot create JDBC driver of class '' for connect URL 'null')
- Codeforces Round #269 (Div. 2)
- Android 获取手机Mac和IP
- MantisBT配置
- service中显示一个dialog
- android:name=".PreferencesActivity" 中的 "." 表示什么
- Java 实现抽象工厂模式
- listView懒加载解决快速拖动卡屏问题
- Control的Invoke和BeginInvoke
- 用双栈实现队的操作
- 品味人生20140928