本文整理匯總了Java中android.net.wifi.SupplicantState.ASSOCIATED屬性的典型用法代碼示例。如果您正苦於以下問題:Java SupplicantState.ASSOCIATED屬性的具體用法?Java SupplicantState.ASSOCIATED怎麽用?Java SupplicantState.ASSOCIATED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.net.wifi.SupplicantState
的用法示例。
在下文中一共展示了SupplicantState.ASSOCIATED屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isWifiConnected
/**
* Check whether WiFi is connected
* @param context a Context instance
* @return true if Wifi is connected
*/
// @RequiresPermission(value = Manifest.permission.ACCESS_WIFI_STATE)
public static boolean isWifiConnected(Context context) {
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null || !wifiManager.isWifiEnabled()) return false;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo == null || wifiInfo.getNetworkId() == -1) return false;
return wifiInfo.getSupplicantState() == SupplicantState.ASSOCIATED;
}
示例2: getWifiIp
private String getWifiIp() {
WifiManager mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
WifiInfo mWifiInfo = mWifiManager.getConnectionInfo();
Log.e("IP in Mask Integer", mWifiInfo.getIpAddress() + "");
Log.e("IP Address", intToIP(mWifiInfo.getIpAddress()) + "");
Log.e("ip-widget", "Supplicant state" + mWifiInfo.getSupplicantState());
if(mWifiManager.isWifiEnabled() && (mWifiInfo.getSupplicantState() == SupplicantState.ASSOCIATED || mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED)) {
return mWifiInfo.getSSID() + " - " + intToIP(mWifiInfo.getIpAddress());
}
return "Disconnected";
}