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


Java WifiInfo.getBSSID方法代码示例

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


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

示例1: getWifiBSSID

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
/**
 * Get the BSSID of the currently-connected WiFi AP
 * @param context a Context instance
 * @return the BSSID of WiFi, or null if the device is not connected
 */
// @RequiresPermission(value = Manifest.permission.ACCESS_WIFI_STATE)
public static String getWifiBSSID(Context context) {
    WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (wifiManager == null || !wifiManager.isWifiEnabled()) return null;
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo == null || wifiInfo.getNetworkId() == -1) return null;
    return wifiInfo.getBSSID();
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:14,代码来源:DeviceUtils.java

示例2: checkIfNewRepoOnSameWifi

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
private void checkIfNewRepoOnSameWifi(NewRepoConfig newRepo) {
    // if this is a local repo, check we're on the same wifi
    if (!TextUtils.isEmpty(newRepo.getBssid())) {
        WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        String bssid = wifiInfo.getBSSID();
        if (TextUtils.isEmpty(bssid)) { /* not all devices have wifi */
            return;
        }
        bssid = bssid.toLowerCase(Locale.ENGLISH);
        String newRepoBssid = Uri.decode(newRepo.getBssid()).toLowerCase(Locale.ENGLISH);
        if (!bssid.equals(newRepoBssid)) {
            String msg = String.format(getString(R.string.not_on_same_wifi), newRepo.getSsid());
            Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        }
        // TODO we should help the user to the right thing here,
        // instead of just showing a message!
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:20,代码来源:ManageReposActivity.java

示例3: 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

示例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: updateWifiInfo

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
private void updateWifiInfo() {
    WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();

    wifiSsid = wifiInfo.getSSID();
    wifiBssid = wifiInfo.getBSSID();
}
 
开发者ID:OpenLocate,项目名称:openlocate-android,代码行数:8,代码来源:InformationFieldsFactory.java

示例6: getRouteMac

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
/**
 * 获取本机MAC地址
 */
public static String getRouteMac() {
    try {
        WifiManager wifiManager = (WifiManager) sContext.getSystemService(Context
                .WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        if (wifiInfo == null) {
            return "0";
        }
        return wifiInfo.getBSSID();
    } catch (SecurityException e) {
        e.printStackTrace();
    }
    return "0";
}
 
开发者ID:jonyChina162,项目名称:okhttpNDS,代码行数:18,代码来源:NetworkManager.java

示例7: onReceive

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    WifiManager wifiManager = (WifiManager) context
            .getSystemService(context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo.getBSSID() != null) {
        // wifi信号强度
        int signalLevel = WifiManager.calculateSignalLevel(
                wifiInfo.getRssi(), 4);
        if (signalLevel == 0) {
            imgNetWorkState.setImageDrawable(context.getResources()
                    .getDrawable(R.drawable.wifi_1));
        } else if (signalLevel == 1) {
            imgNetWorkState.setImageDrawable(context.getResources()
                    .getDrawable(R.drawable.wifi_2));

        } else if (signalLevel == 2) {
            imgNetWorkState.setImageDrawable(context.getResources()
                    .getDrawable(R.drawable.wifi_3));

        } else if (signalLevel == 3) {
            imgNetWorkState.setImageDrawable(context.getResources()
                    .getDrawable(R.drawable.networkstate_on));
        }
        if (d)
            Toast.makeText(context, "wifi level" + signalLevel,
                    Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:30,代码来源:GameTitleView.java

示例8: onReceive

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	WifiManager wifiManager = (WifiManager) context
			.getSystemService(context.WIFI_SERVICE);
	WifiInfo wifiInfo = wifiManager.getConnectionInfo();
	if (wifiInfo.getBSSID() != null) {
		// wifi信号强度
		int signalLevel = WifiManager.calculateSignalLevel(
				wifiInfo.getRssi(), 4);
		if (signalLevel == 0) {
			imgNetWorkState.setImageDrawable(context.getResources()
					.getDrawable(R.drawable.wifi_1));

		} else if (signalLevel == 1) {
			imgNetWorkState.setImageDrawable(context.getResources()
					.getDrawable(R.drawable.wifi_2));

		} else if (signalLevel == 2) {
			imgNetWorkState.setImageDrawable(context.getResources()
					.getDrawable(R.drawable.wifi_3));

		} else if (signalLevel == 3) {
			imgNetWorkState.setImageDrawable(context.getResources()
					.getDrawable(R.drawable.networkstate_on));
		}
		if (d)
			Toast.makeText(context, "wifi level" + signalLevel,
					Toast.LENGTH_SHORT).show();
	}
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:31,代码来源:TitleView.java

示例9: getBssid

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
public String getBssid() {
    WifiManager wifiManager = (WifiManager) getSystemService("wifi");
    if (wifiManager == null) {
        return null;
    }
    WifiInfo connectionInfo = wifiManager.getConnectionInfo();
    if (connectionInfo == null) {
        return null;
    }
    String bssid = connectionInfo.getBSSID();
    if (bssid == null) {
        bssid = null;
    }
    return bssid;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:DeviceHelper.java

示例10: C

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
public static String C(Context context) {
    try {
        WifiInfo B = B(context);
        if (B != null) {
            return B.getBSSID();
        }
    } catch (Object th) {
        f.e(th);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:k.java

示例11: U

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
public static String U(Context context) {
    try {
        WifiInfo T = T(context);
        if (T != null) {
            return T.getBSSID();
        }
    } catch (Throwable th) {
        Log.e("MtaSDK", "encode error", th);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:r.java

示例12: c

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
private static String c(Context context) {
    WifiInfo connectionInfo = ((WifiManager) context.getSystemService("wifi")).getConnectionInfo();
    if (connectionInfo != null) {
        return connectionInfo.getBSSID();
    }
    return "00";
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:c.java

示例13: d

import android.net.wifi.WifiInfo; //导入方法依赖的package包/类
private List<k> d() {
    z.a();
    if (!a()) {
        return new ArrayList();
    }
    k kVar;
    WifiInfo connectionInfo = this.a.getConnectionInfo();
    if (connectionInfo != null) {
        k kVar2 = new k(this, connectionInfo.getBSSID(), connectionInfo.getRssi(), connectionInfo.getSSID());
        new StringBuilder(z[6]).append(kVar2.toString());
        kVar = kVar2;
        z.a();
    } else {
        kVar = null;
    }
    ArrayList arrayList = new ArrayList();
    if (kVar != null) {
        arrayList.add(kVar);
    }
    List scanResults = VERSION.SDK_INT < 23 ? this.a.getScanResults() : (this.b == null || !a.c(this.b, z[5])) ? null : this.a.getScanResults();
    if (r0 != null && r0.size() > 0) {
        int i = -200;
        k kVar3 = null;
        for (ScanResult kVar4 : r0) {
            int i2;
            k kVar5 = new k(this, kVar4);
            if (kVar5.c.equals(kVar.c) || kVar5.b <= i) {
                kVar2 = kVar3;
                i2 = i;
            } else {
                new StringBuilder(z[4]).append(kVar5.toString());
                z.a();
                k kVar6 = kVar5;
                i2 = kVar5.b;
                kVar2 = kVar6;
            }
            kVar3 = kVar2;
            i = i2;
        }
        if (kVar3 != null) {
            arrayList.add(kVar3);
        }
    }
    return arrayList;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:46,代码来源:j.java


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