mac访问android手机机怎么连mac

* 获取手机mac地址&br/&
* 错误返回12个0
public static String getMacAddress(Context context) {
// 获取mac地址:
String macAddress = "";
WifiManager wifiMgr = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = (null == wifiMgr ? null : wifiMgr
.getConnectionInfo());
if (null != info) {
if (!TextUtils.isEmpty(info.getMacAddress()))
macAddress = info.getMacAddress().replace(":", "");
return macA
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return macA
return macA
获取手机名称
android.os.Build.MANUFACTURER
阅读(...) 评论()记住登录一个月发表随想还能输入:200字该用户最新代码编程随想&by by by by by by [android]代码库//需要添加权限:
//&uses-permission android:name="android.permission.ACCESS_WIFI_STATE"&&/uses-permission&
//&uses-permission android:name="android.permission.INTERNET"&&/uses-permission&
package exp.
import java.net.InetA
import java.net.NetworkI
import java.net.SocketE
import java.util.E
import android.app.A
import android.content.C
import android.net.wifi.WifiI
import android.net.wifi.WifiM
import android.os.B
import android.util.L
import android.widget.TextV
public class GetIPMAC extends Activity
public static S
public static S
/** Called when the activity is first created. */
public void onCreate (Bundle savedInstanceState)
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
TextView tv = (TextView) findViewById (R.id.hello);
hostip = getLocalIpAddress();
//获取本机IP
hostmac = getLocalMacAddress();//获取本机MAC
/* 本机IP和MAC */
tv.setText ("HostIP:" + hostip + "\nHostMAC:" + hostmac);
/* 打印本机IP和MAC */
if (hostip != null)
Log.d ("GetIPMAC", hostip);
Log.d ("GetIPMAC", "null");
Log.d ("GetIPMAC", hostmac);
public String getLocalIpAddress()
for (Enumeration&NetworkInterface& en = NetworkInterface
.getNetworkInterfaces(); en.hasMoreElements();)
NetworkInterface intf = en.nextElement();
for (Enumeration&InetAddress& enumIpAddr = intf
.getInetAddresses(); enumIpAddr.hasMoreElements();)
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress() )
return inetAddress.getHostAddress().toString();
catch (SocketException ex)
Log.e ("WifiPreference IpAddress", ex.toString() );
public String getLocalMacAddress()
WifiManager wifi = (WifiManager) getSystemService (Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
return info.getMacAddress();
}分享到:更多共2 条评论
发表评论:评论须知:1、评论每次加2分,每天上限为30;2、请文明用语,共同创建干净的技术交流环境;3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。您所在的位置: &
小米2及其他Android手机无法连接mac解决方案
小米2及其他Android手机无法连接mac解决方案
有没有遇到这种情况的朋友,自己的小米2或其他Android手机无法连接mac?下面教给大家一个简单的方法解决这个问题,只需在mac的终端输入一行命令即可。希望对大家有所帮助。
一般的android连接mac 很方便不用安装驱动就可以啦,可是不知道为什么二般情况下有的android手机(小米2,华为等)就是连接不上,下来就说说二般情况下如何连接。
1.关于本机--&更多信息-&概系统览-&系统报告-&usb-&你所连接的device--&供应商ID(Vendor
498)this.width=498;' onmousewheel = 'javascript:return big(this)' width="480" height="332" alt="" src="/files/uploadimg/8380.png" />
2.终端执行如下命令:
&&&&echo 0x2717 && ~/.android/adb_usb.ini
3.重启 adb &去DDMS 看看 有啦!!
从而解决了小米2及其他android手机无法连接mac的问题。【编辑推荐】【责任编辑: TEL:(010)】
关于&&的更多文章
Android 4.4即将发布,这对大家来说都是很期待的,当然,无论是
既然强大的Android Studio来了,有什么理由不去用呢?
App搜索对应用的影响不容忽视,目前应用商店仍采用最
当下,移动App的开发相当火热,Android的和iOS的开发
关于App营销,了解哪类App最能引起用户关注,以及不同
程序设计实践并不只是写代码。程序员必须评论各种折衷方案,在许多可能性之中做出选择、排除错误、做测试和改进程序性能,还要维
Windows Phone专家
Android开发专家
51CTO旗下网站}

我要回帖

更多关于 mac连接android手机 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信