@Override public void onReceive(Context context, Intent intent){ SupplicantState state = intent.getParcelableExtra(EXTRA_NEW_STATE); if(state != null){ if(state.equals(SupplicantState.COMPLETED)){ onSuccessfulConnection(); } else if(state.equals(SupplicantState.DISCONNECTED)){ onFailedConnection(); } } } }
@Override public void onReceive(Context context, Intent intent) { WifiInfo wifiInfo = wfmgr.getConnectionInfo(); Log.d(Constants.TAG, "WearMenuFragment checkConnection wifiInfo.getSupplicantState: " + wifiInfo.getSupplicantState()); Log.d(Constants.TAG, "WearMenuFragment checkConnection wifiInfo.SSID: " + wifiInfo.getSSID()); Log.d(Constants.TAG, "WearMenuFragment checkConnection action: " + intent.getAction()); Log.d(Constants.TAG, "WearMenuFragment checkConnection connected: " + intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); if (intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) { if (wifiInfo.getSupplicantState().toString().equals("COMPLETED")) if (receiverSSID == null) getSSID(); } else { vibrator.vibrate(100); Toast.makeText(mContext, "Wi-Fi Disconnected", Toast.LENGTH_SHORT).show(); } } };
@Override public void onReceive(Context context, Intent intent) { WifiInfo wifiInfo = wfmgr.getConnectionInfo(); Log.d(Constants.TAG, "AmazModLauncher checkConnection wifiInfo.getSupplicantState: " + wifiInfo.getSupplicantState()); Log.d(Constants.TAG, "AmazModLauncher checkConnection wifiInfo.SSID: " + wifiInfo.getSSID()); Log.d(Constants.TAG, "AmazModLauncher checkConnection action: " + intent.getAction()); Log.d(Constants.TAG, "AmazModLauncher checkConnection connected: " + intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); if (intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) { if (wifiInfo.getSupplicantState().toString().equals("COMPLETED")) if (receiverSSID == null) getSSID(); } else { vibrator.vibrate(100); Toast.makeText(mContext, "Wi-Fi Disconnected", Toast.LENGTH_SHORT).show(); } } };
@Override public void onReceive(Context context, Intent intent) { WifiInfo wifiInfo = wfmgr.getConnectionInfo(); Log.d(Constants.TAG, "WearMenuFragment getSSID wifiInfo.getSupplicantState: " + wifiInfo.getSupplicantState()); Log.d(Constants.TAG, "WearMenuFragment getSSID wifiInfo.SSID: " + wifiInfo.getSSID()); Log.d(Constants.TAG, "WearMenuFragment getSSID action: " + intent.getAction()); Log.d(Constants.TAG, "WearMenuFragment getSSID connected: " + intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); if (wifiInfo.getSupplicantState().equals(SupplicantState.ASSOCIATED)) flag = true; if (wifiInfo.getSupplicantState().equals(SupplicantState.COMPLETED) && flag) { flag = false; vibrator.vibrate(100); Toast.makeText(mContext, "Wi-Fi Connected to:\n" + wifiInfo.getSSID(), Toast.LENGTH_SHORT).show(); } } };
@Override public void onReceive(Context context, Intent intent) { WifiInfo wifiInfo = wfmgr.getConnectionInfo(); Log.d(Constants.TAG, "WearActivity checkConnection wifiInfo.getSupplicantState: " + wifiInfo.getSupplicantState()); Log.d(Constants.TAG, "WearActivity checkConnection wifiInfo.SSID: " + wifiInfo.getSSID()); Log.d(Constants.TAG, "WearActivity checkConnection action: " + intent.getAction()); Log.d(Constants.TAG, "WearActivity checkConnection connected: " + intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); if (intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) { if (wifiInfo.getSupplicantState().toString().equals("COMPLETED")) if (receiverSSID == null) getSSID(); } else { vibrator.vibrate(100); Toast.makeText(getApplicationContext(), "Wi-Fi Disconnected", Toast.LENGTH_SHORT).show(); } } };
@Override public void onReceive(Context context, Intent intent) { WifiInfo wifiInfo = wfmgr.getConnectionInfo(); Log.d(Constants.TAG, "AmazModLauncher getSSID wifiInfo.getSupplicantState: " + wifiInfo.getSupplicantState()); Log.d(Constants.TAG, "AmazModLauncher getSSID wifiInfo.SSID: " + wifiInfo.getSSID()); Log.d(Constants.TAG, "AmazModLauncher getSSID action: " + intent.getAction()); Log.d(Constants.TAG, "AmazModLauncher getSSID connected: " + intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); if (wifiInfo.getSupplicantState().equals(SupplicantState.ASSOCIATED)) flag = true; if (wifiInfo.getSupplicantState().equals(SupplicantState.COMPLETED) && flag) { flag = false; vibrator.vibrate(100); Toast.makeText(mContext, "Wi-Fi Connected to:\n" + wifiInfo.getSSID(), Toast.LENGTH_SHORT).show(); } } };
@SuppressLint("HardwareIds") @Override public void writeJson(JsonWriter out) throws Exception { WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiInfo info = manager.getConnectionInfo(); out.beginObject(); if (info == null) { out.name("API_ERROR").value("No current connection"); } else { out.name("bssid").value(info.getBSSID()); out.name("frequency_mhz").value(info.getFrequency()); //noinspection deprecation - formatIpAddress is deprecated, but we only have a ipv4 address here: out.name("ip").value(Formatter.formatIpAddress(info.getIpAddress())); out.name("link_speed_mbps").value(info.getLinkSpeed()); out.name("mac_address").value(info.getMacAddress()); out.name("network_id").value(info.getNetworkId()); out.name("rssi").value(info.getRssi()); out.name("ssid").value(info.getSSID().replaceAll("\"", "")); out.name("ssid_hidden").value(info.getHiddenSSID()); out.name("supplicant_state").value(info.getSupplicantState().toString()); } out.endObject(); } });
@Override public void onReceive(Context context, Intent intent) { WifiInfo wifiInfo = wfmgr.getConnectionInfo(); Log.d(Constants.TAG, "WearActivity getSSID wifiInfo.getSupplicantState: " + wifiInfo.getSupplicantState()); Log.d(Constants.TAG, "WearActivity getSSID wifiInfo.SSID: " + wifiInfo.getSSID()); Log.d(Constants.TAG, "WearActivity getSSID action: " + intent.getAction()); Log.d(Constants.TAG, "WearActivity getSSID connected: " + intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)); if (wifiInfo.getSupplicantState().equals(SupplicantState.ASSOCIATED)) flag = true; if (wifiInfo.getSupplicantState().equals(SupplicantState.COMPLETED) && flag) { flag = false; vibrator.vibrate(100); Toast.makeText(getApplicationContext(), "Wi-Fi Connected to:\n" + wifiInfo.getSSID(), Toast.LENGTH_SHORT).show(); } } };