当前位置: 首页>>代码示例>>Java>>正文


Java WifiInfo类代码示例

本文整理汇总了Java中android.net.wifi.WifiInfo的典型用法代码示例。如果您正苦于以下问题:Java WifiInfo类的具体用法?Java WifiInfo怎么用?Java WifiInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WifiInfo类属于android.net.wifi包,在下文中一共展示了WifiInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWifiSSID

import android.net.wifi.WifiInfo; //导入依赖的package包/类
/**
 * Gets the SSID of the currently associated WiFi access point if there is one. Otherwise,
 * returns empty string.
 */
@CalledByNative
public static String getWifiSSID(Context context) {
    if (context == null) {
        return "";
    }
    final Intent intent = context.registerReceiver(
            null, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));
    if (intent != null) {
        final WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO);
        if (wifiInfo != null) {
            final String ssid = wifiInfo.getSSID();
            if (ssid != null) {
                return ssid;
            }
        }
    }
    return "";
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:23,代码来源:AndroidNetworkLibrary.java

示例2: GetWifiDBM

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public int GetWifiDBM() {
    int dbm = 0;

    WifiManager wifiManager = (WifiManager) _context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null) {
        return -1;
    }

    if (wifiManager.isWifiEnabled()) {
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        if (wifiInfo != null) {
            dbm = wifiInfo.getRssi();
        }
    }

    return dbm;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:18,代码来源:NetworkController.java

示例3: getIpAddress

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static int getIpAddress() {
    int ipAddress = 0;
    WifiManager wifiManager = (WifiManager) FDApplication
            .getInstance().getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo == null || wifiInfo.equals("")) {
        return ipAddress;
    } else {
        ipAddress = wifiInfo.getIpAddress();
    }
    return ipAddress;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:StrUtils.java

示例4: b4

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public String b4() {
    WifiInfo connectionInfo = this.hV.getConnectionInfo();
    if (connectionInfo == null) {
        return null;
    }
    try {
        String bssid = connectionInfo.getBSSID();
        if (bssid != null) {
            bssid = bssid.replace(":", "");
            if ("000000000000".equals(bssid) || "".equals(bssid)) {
                return null;
            }
        }
        bssid = null;
        return bssid;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:ar.java

示例5: getMacAddressByWifiInfo

import android.net.wifi.WifiInfo; //导入依赖的package包/类
/**
 * <p>need permission {@code <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>}</p>
 */
@SuppressLint("HardwareIds")
private static String getMacAddressByWifiInfo(Context context) {
    try {
        WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        if (wifi != null) {
            WifiInfo info = wifi.getConnectionInfo();
            if (info != null) return info.getMacAddress();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "02:00:00:00:00:00";
}
 
开发者ID:ChangsenLai,项目名称:codedemos,代码行数:17,代码来源:DeviceUtil.java

示例6: onReceive

import android.net.wifi.WifiInfo; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent)
{
    WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
    String name = wifiInfo.getSSID();
    for(ScanResult result: wifiMgr.getScanResults()){
        WifiApListProvider.this.output(new WifiAp(result, name.equals(result.SSID)));
    }
    WifiApListProvider.this.finish();
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:12,代码来源:WifiApListProvider.java

示例7: getDeviceId

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static String getDeviceId(Context context) {
    String deviceID = null;
    // MAC
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info;
    if (wifi != null && (info = wifi.getConnectionInfo()) != null) {
        deviceID = info.getMacAddress();
    }
    // TelephonyManager.DeviceId
    String tmSerial = "null";
    if (TextUtils.isEmpty(deviceID)) {
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm != null) {
            tmSerial = "" + tm.getSimSerialNumber();
            deviceID = tm.getDeviceId();
        }
    }
    // Settings.Secure.ANDROID_ID + TelephonyManager.SimSerialNumber
    if (TextUtils.isEmpty(deviceID)) {
        deviceID = generateId(context, tmSerial);
    }
    return deviceID;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:24,代码来源:DeviceUtil.java

示例8: getDeviceIpAddress

import android.net.wifi.WifiInfo; //导入依赖的package包/类
private InetAddress getDeviceIpAddress(WifiManager wifi) {
	InetAddress result = null;
	try {
		// default to Android localhost
		result = InetAddress.getByName("10.0.0.2");

		// figure out our wifi address, otherwise bail
		WifiInfo wifiinfo = wifi.getConnectionInfo();
		int intaddr = wifiinfo.getIpAddress();
		byte[] byteaddr = new byte[] { (byte) (intaddr & 0xff), (byte) (intaddr >> 8 & 0xff), (byte) (intaddr >> 16 & 0xff), (byte) (intaddr >> 24 & 0xff) };
		result = InetAddress.getByAddress(byteaddr);
	} catch (UnknownHostException e) {
		e.printStackTrace();
		Log.e(TAG, "getDeviceIpAddress Error: " + e.getMessage());
	}

	return result;
}
 
开发者ID:hoanglm4,项目名称:RxAndroidTBP,代码行数:19,代码来源:MDnsHelper.java

示例9: isHotelNewWork

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static boolean isHotelNewWork(Context context) {
    WifiManager wifiManger = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    //获取wifi服务
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    //判断wifi是否开启
    if (!wifiManager.isWifiEnabled()) {
        return false;
    }else {
        WifiInfo wifiInfo = wifiManger.getConnectionInfo();
        String localIp = intToIp(wifiInfo.getIpAddress());
        if("192.168.43".equals(localIp))
            return true;
        else
            return false;
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:17,代码来源:WifiUtil.java

示例10: a

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static String a() {
    try {
        Context context = Global.getContext();
        if (context == null) {
            return "";
        }
        WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
        if (wifiManager == null) {
            return "";
        }
        WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        if (connectionInfo == null) {
            return "";
        }
        return connectionInfo.getMacAddress();
    } catch (Throwable e) {
        f.b("MobileInfoUtil", "getLocalMacAddress>>>", e);
        return "";
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:c.java

示例11: getConnectedSSID

import android.net.wifi.WifiInfo; //导入依赖的package包/类
/**
 * This method retrieves the SSID for the currently connected network
 *
 *    @param    callbackContext        A Cordova callback context
 *    @return    true if SSID found, false if not.
*/
private boolean getConnectedSSID(CallbackContext callbackContext){
    if(!wifiManager.isWifiEnabled()){
        callbackContext.error("Wifi is disabled");
        return false;
    }

    WifiInfo info = wifiManager.getConnectionInfo();

    if(info == null){
        callbackContext.error("Unable to read wifi info");
        return false;
    }

    String ssid = info.getSSID();
    if(ssid.isEmpty()) {
        ssid = info.getBSSID();
    }
    if(ssid.isEmpty()){
        callbackContext.error("SSID is empty");
        return false;
    }

    callbackContext.success(ssid);
    return true;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:32,代码来源:WifiWizard.java

示例12: getCurrentSSID

import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static String getCurrentSSID(Context context) throws Exception {
    try {
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        return wifiInfo.getSSID();
    } catch (Exception e) {
        throw new Exception("目前WIFI連線名稱讀取時發生錯誤");
    }

}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:12,代码来源:WifiUtility.java

示例13: checkWifiConnection

import android.net.wifi.WifiInfo; //导入依赖的package包/类
private void checkWifiConnection(){
    try{
        if(isWifiConnected()){
            Toast.makeText(getApplicationContext(), "Wifi is connected", Toast.LENGTH_SHORT).show();
            WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
            WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            final String activeWifiName = wifiInfo.getSSID().replace("\"","");
            btnActiveWifi.setText(activeWifiName);
            //debug
            btnActiveWifi.setText(btnActiveWifi.getText()+"\n("+AutoLoginService.getState(getBaseContext())+")");

        }
        else{
            btnActiveWifi.setText("Wifi Not Connected !!");
            //debug
            btnActiveWifi.setText(btnActiveWifi.getText()+"\n("+AutoLoginService.getState(getBaseContext())+")");

        }}
    catch (Exception ex){
        txtView.setText(ex.getMessage());
        //Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG);
    }
}
 
开发者ID:debjeetmaj,项目名称:AndroidWifiAutoLogin,代码行数:24,代码来源:MainActivity.java

示例14: onBindHooks

import android.net.wifi.WifiInfo; //导入依赖的package包/类
@Override
protected void onBindHooks() {
	super.onBindHooks();
	addHook(new StaticHook("getConnectionInfo") {
		@Override
		public Object call(Object who, Method method, Object... args) throws Throwable {
			WifiInfo info = (WifiInfo) super.call(who, method, args);
			if (info != null) {
				if (info.getMacAddress() != null) {
					PhoneInfoDelegate phoneInfoDelegate = VirtualCore.get().getPhoneInfoDelegate();
					if (phoneInfoDelegate != null) {
						try {
							Reflect.on(info).set("mMacAddress", phoneInfoDelegate.getMacAddress((String) Reflect.on(info).get("mMacAddress")));
						} catch (Exception ignored) {
						}
					}
				}
			}
			return info;
		}
	});
}
 
开发者ID:codehz,项目名称:container,代码行数:23,代码来源:WifiManagerPatch.java

示例15: getMacAddress

import android.net.wifi.WifiInfo; //导入依赖的package包/类
@SuppressLint("HardwareIds")
public String getMacAddress() throws Exception {
    WifiManager wifiMan = (WifiManager) mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (wifiMan == null) {
        return null;
    }
    WifiInfo wifiInf = wifiMan.getConnectionInfo();
    if (wifiInf == null) {
        return getMacByFile();
    }

    String mac = wifiInf.getMacAddress();
    if (FAKE_MAC_ADDRESS.equals(mac)) {
        mac = null;
    }
    if (mac == null) {
        mac = getMacByInterface();
        if (mac == null) {
            mac = getMacByFile();
        }
    }
    return mac;
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:24,代码来源:Device.java


注:本文中的android.net.wifi.WifiInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。