編輯:關於Android編程
/** * 獲取ip * * @return */ public static String getLocalIPAddress() { try { for (Enumerationen = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration enumIpAddr = intf .getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) { // return inetAddress.getAddress().toString(); return inetAddress.getHostAddress().toString(); } } } } catch (SocketException ex) { Log.e("BaseScanTvDeviceClient", "獲取本機IP false =" + ex.toString()); } return null; } public static String getLocalIPAddress(Context context) { WifiManager wifiManager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); String ipAddress = FormatIP(wifiInfo.getIpAddress()); return ipAddress; } public static String FormatIP(int ip) { return Formatter.formatIpAddress(ip); } // /獲取本機IP地址 public static String getLocalIpAddress(Context ctx) { WifiManager wifiManager = (WifiManager) ctx .getSystemService(android.content.Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); try { return InetAddress.getByName( String.format("%d.%d.%d.%d", (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff))).toString(); } catch (UnknownHostException e) { return null; } } // 獲取本機的物理地址 public static String getLocalMacAddress(Context ctx) { WifiManager wifi = (WifiManager) ctx .getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); return info.getMacAddress(); }
按照我一開始的打算,上面一篇文章應該是“Android動畫總結系列(5)——屬性動畫源碼分析”,不過屬性動畫源碼分析寫起來
hello,上篇我們已經分析6種Drawable的使用方法,本篇咱們就繼續剩下的Drawable~,閒話莫多說,那就直接開始吧。7、TransitionDrawable很
前段時間,項目中用到了沉浸式的狀態欄,在此記錄一下,代碼如下:package com.jackie.immersive; import android.os.Build
前言:前面介紹了瀑布流的基本實現,實際上瀑布流還有一些事件需要監聽。比如點擊事件,下拉和上拉事件。這裡接著上次的 android—UI—Recyc