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


Java WifiManager.calculateSignalLevel方法代码示例

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


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

示例1: onReceive

import android.net.wifi.WifiManager; //导入方法依赖的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

示例2: onReceive

import android.net.wifi.WifiManager; //导入方法依赖的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

示例3: onRequestPermissionsResult

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    if (requestCode == 0x12345) {
        for (int grantResult : grantResults) {
            if (grantResult != PackageManager.PERMISSION_GRANTED) {
                return;
            }
        }
        WifiManager myWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        boolean wasEnabled = myWifiManager.isWifiEnabled();
        if (!wasEnabled)
            myWifiManager.setWifiEnabled(true);
        if (myWifiManager.isWifiEnabled()) {
            if (myWifiManager.startScan()) {
                // List available APs
                Log.d("pras", "this inside scan");
                List<ScanResult> scans = myWifiManager.getScanResults();
                Log.d("pras", "" + (scans == null));
                Log.d("pras", "" + scans.isEmpty());
                if (scans != null && !scans.isEmpty()) {
                    for (ScanResult scan : scans) {
                        int level = WifiManager.calculateSignalLevel(scan.level, 20);
                        //Other code
                        Log.d("wifi", level + "this");
                    }
                } else {
                    Log.d("pras", "this inside else");
                }
            }
        }

    }

}
 
开发者ID:PrasannaNatarajan,项目名称:Interrobang,代码行数:35,代码来源:MainActivity.java

示例4: getSignalLevel

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
public static int getSignalLevel() {
    WifiInfo wifiInfo = sWifiManager.getConnectionInfo();
    return WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 5);
}
 
开发者ID:jiangkang,项目名称:KTools,代码行数:5,代码来源:NetworkUtils.java

示例5: getBars

import android.net.wifi.WifiManager; //导入方法依赖的package包/类
/**
 * Get the number of bars in the range 1 - 4.
 *
 * @return
 */
public int getBars() {
    return WifiManager.calculateSignalLevel(level, 5);
}
 
开发者ID:KennethEvans,项目名称:Misc,代码行数:9,代码来源:WifiActivity.java


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