本文整理了Java中android.net.wifi.WifiInfo.getSSID()
方法的一些代码示例,展示了WifiInfo.getSSID()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WifiInfo.getSSID()
方法的具体详情如下:
包路径:android.net.wifi.WifiInfo
类名称:WifiInfo
方法名:getSSID
暂无
代码示例来源:origin: cSploit/android
public String getSSID() {
String res = mWifiInfo.getSSID();
return res.equals("
}
代码示例来源:origin: stackoverflow.com
public class WifiReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if(info != null && info.isConnected()) {
// Do your work.
// e.g. To check the Network Name or other info:
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String ssid = wifiInfo.getSSID();
}
}
}
代码示例来源:origin: stackoverflow.com
public static String getCurrentSsid(Context context) {
String ssid = null;
ConnectivityManager cOnnManager= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (networkInfo.isConnected()) {
final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
final WifiInfo cOnnectionInfo= wifiManager.getConnectionInfo();
if (connectionInfo != null && !StringUtil.isBlank(connectionInfo.getSSID())) {
ssid = connectionInfo.getSSID();
}
}
return ssid;
}
代码示例来源:origin: stackoverflow.com
public static String getCurrentSsid(Context context) {
String ssid = null;
ConnectivityManager cOnnManager= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (networkInfo.isConnected()) {
final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
final WifiInfo cOnnectionInfo= wifiManager.getConnectionInfo();
if (connectionInfo != null && !TextUtils.isEmpty(connectionInfo.getSSID())) {
ssid = connectionInfo.getSSID();
}
}
return ssid;
}
代码示例来源:origin: stackoverflow.com
WifiManager wifiManager = (WifiManager) getSystemService (Context.WIFI_SERVICE);
WifiInfo info = wifiManager.getConnectionInfo ();
String ssid = info.getSSID();
代码示例来源:origin: smuyyh/BookReader
/**
* 获取当前连接wifi的名称
*
* @return
*/
public static String getConnectWifiSsid(Context context) {
if (isWifiConnected(context)) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
return wifiInfo.getSSID();
}
return null;
}
代码示例来源:origin: stackoverflow.com
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
Log.d("wifiInfo", wifiInfo.toString());
Log.d("SSID",wifiInfo.getSSID());
代码示例来源:origin: facebook/facebook-android-sdk
@Override
public WifiScanResult getConnectedWifi() throws ScannerException {
try {
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo == null
|| TextUtils.isEmpty(wifiInfo.getBSSID())
|| wifiInfo.getSupplicantState() != SupplicantState.COMPLETED
|| isWifiSsidBlacklisted(wifiInfo.getSSID())) {
return null;
}
WifiScanResult wifiScanResult = new WifiScanResult();
wifiScanResult.bssid = wifiInfo.getBSSID();
wifiScanResult.ssid = wifiInfo.getSSID();
wifiScanResult.rssi = wifiInfo.getRssi();
wifiScanResult.timestampMs = SystemClock.elapsedRealtime();
if (Build.VERSION.SDK_INT >= ScannerFactory.OS_VERSION_LOLLIPOP) {
wifiScanResult.frequency = wifiInfo.getFrequency();
}
return wifiScanResult;
} catch (Exception e) {
throw new ScannerException(ScannerException.Type.UNKNOWN_ERROR, e);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = Build.VERSION_CODES.KITKAT)
public void connect_setsConnectionInfo() throws Exception {
// GIVEN
WifiConfiguration wifiCOnfiguration= new WifiConfiguration();
wifiConfiguration.SSID = "foo";
// WHEN
wifiManager.connect(wifiConfiguration, null);
// THEN
assertThat(wifiManager.getConnectionInfo().getSSID()).contains("foo");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldReturnSSID() {
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
shadowOf(wifiInfo).setSSID("SSID");
wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getSSID()).contains("SSID");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void reconnect_setsConnectionInfo() {
// GIVEN
WifiConfiguration wifiCOnfiguration= new WifiConfiguration();
wifiConfiguration.SSID = "SSID";
int netId = wifiManager.addNetwork(wifiConfiguration);
wifiManager.enableNetwork(netId, false);
// WHEN
wifiManager.reconnect();
// THEN
assertThat(wifiManager.getConnectionInfo().getSSID()).contains("SSID");
}
代码示例来源:origin: syncthing/syncthing-android
private boolean isWifiConnectionWhitelisted(Set
WifiManager wifiManager = (WifiManager) mContext.getApplicationContext()
.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo == null) {
// May be null, if wifi has been turned off in the meantime.
Log.d(TAG, "isWifiConnectionWhitelisted: SSID unknown due to wifiInfo == null");
return false;
}
String wifiSsid = wifiInfo.getSSID();
if (wifiSsid == null) {
Log.w(TAG, "isWifiConnectionWhitelisted: Got null SSID. Try to enable android location service.");
return false;
}
return whitelistedSsids.contains(wifiSsid);
}
代码示例来源:origin: kingthy/TVRemoteIME
public static String getSSID(Context context) {
if (cOntext== null) {
XLLog.e(TAG, "getSSID, context invalid");
return null;
}
WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
if (wifiManager != null) {
WifiInfo cOnnectionInfo= wifiManager.getConnectionInfo();
if (connectionInfo != null) {
return connectionInfo.getSSID();
}
}
return null;
}
代码示例来源:origin: stackoverflow.com
public String getWifiName(Context context) {
WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (manager.isWifiEnabled()) {
WifiInfo wifiInfo = manager.getConnectionInfo();
if (wifiInfo != null) {
DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
if (state == DetailedState.CONNECTED || state == DetailedState.OBTAINING_IPADDR) {
return wifiInfo.getSSID();
}
}
}
return null;
}
代码示例来源:origin: stackoverflow.com
final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
final WifiInfo cOnnectionInfo= wifiManager.getConnectionInfo();
if (connectionInfo != null && !(connectionInfo.getSSID().equals(""))) {
ssid = connectionInfo.getSSID();
代码示例来源:origin: ac-pm/Inspeckage
String ssid = wi.getSSID();
li.add(new FingerprintItem("Wi-Fi", "SSID", ssid.substring(1, ssid.length() - 1), ssid.substring(1, ssid.length() - 1), false));
String ipAddress = Formatter.formatIpAddress(wi.getIpAddress());
代码示例来源:origin: zhihu/mirror
public static String getCurrentSSID(Context context) {
WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
return info != null && !TextUtils.isEmpty(info.getSSID()) ? info.getSSID() : context.getString(R.string.connect_status_default_ssid);
}
}
代码示例来源:origin: stackoverflow.com
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (wifiManager != null) {
WifiInfo info = wifiManager.getConnectionInfo();
if (info != null) {
String ssid = info.getSSID();
...
}
}
代码示例来源:origin: stackoverflow.com
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState()) == NetworkInfo.DetailedState.CONNECTED) {
String ssid = wifiInfo.getSSID();
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
@NonNull
WiFiConnection transformWifiInfo(WifiInfo wifiInfo) {
if (wifiInfo == null || wifiInfo.getNetworkId() == -1) {
return WiFiConnection.EMPTY;
}
return new WiFiConnection(
WiFiUtils.convertSSID(wifiInfo.getSSID()),
wifiInfo.getBSSID(),
WiFiUtils.convertIpAddress(wifiInfo.getIpAddress()),
wifiInfo.getLinkSpeed());
}