Search in sources :

Example 21 with WifiManager

use of android.net.wifi.WifiManager in project ExoPlayer by google.

the class HostActivity method onStart.

@Override
public void onStart() {
    Context appContext = getApplicationContext();
    WifiManager wifiManager = (WifiManager) appContext.getSystemService(Context.WIFI_SERVICE);
    wifiLock = wifiManager.createWifiLock(getWifiLockMode(), TAG);
    wifiLock.acquire();
    PowerManager powerManager = (PowerManager) appContext.getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    wakeLock.acquire();
    super.onStart();
}
Also used : Context(android.content.Context) PowerManager(android.os.PowerManager) WifiManager(android.net.wifi.WifiManager)

Example 22 with WifiManager

use of android.net.wifi.WifiManager in project XobotOS by xamarin.

the class MccTable method setWifiCountryCodeFromMcc.

/**
     * If the number of allowed wifi channels has not been set, set it based on
     * the MCC of the SIM.
     * @param phone PhoneBase to act on (get context from).
     * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA)
     */
private static void setWifiCountryCodeFromMcc(PhoneBase phone, int mcc) {
    String country = MccTable.countryCodeForMcc(mcc);
    if (!country.isEmpty()) {
        Context context = phone.getContext();
        Log.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country);
        WifiManager wM = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        //persist
        wM.setCountryCode(country, true);
    }
}
Also used : Context(android.content.Context) WifiManager(android.net.wifi.WifiManager)

Example 23 with WifiManager

use of android.net.wifi.WifiManager in project Android-Debug-Database by amitshekhariitbhu.

the class NetworkUtils method getAddressLog.

public static String getAddressLog(Context context, int port) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
    final String formatedIpAddress = String.format("%d.%d.%d.%d", (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff));
    return "Open http://" + formatedIpAddress + ":" + port + " in your browser";
}
Also used : WifiManager(android.net.wifi.WifiManager)

Example 24 with WifiManager

use of android.net.wifi.WifiManager in project carat by amplab.

the class SamplingLibrary method getWifiState.

/* Get Wifi state: */
public static String getWifiState(Context context) {
    WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    int wifiState = myWifiManager.getWifiState();
    switch(wifiState) {
        case WifiManager.WIFI_STATE_DISABLED:
            return WIFI_STATE_DISABLED;
        case WifiManager.WIFI_STATE_DISABLING:
            return WIFI_STATE_DISABLING;
        case WifiManager.WIFI_STATE_ENABLED:
            return WIFI_STATE_ENABLED;
        case WifiManager.WIFI_STATE_ENABLING:
            return WIFI_STATE_ENABLING;
        default:
            return WIFI_STATE_UNKNOWN;
    }
}
Also used : WifiManager(android.net.wifi.WifiManager)

Example 25 with WifiManager

use of android.net.wifi.WifiManager in project carat by amplab.

the class SamplingLibrary method getWifiMacAddress.

/**
	 * Get Wifi MAC ADDR. Hashed and used in UUID calculation.
	 */
private static String getWifiMacAddress(Context context) {
    WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (myWifiManager == null)
        return null;
    WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
    if (myWifiInfo == null)
        return null;
    return myWifiInfo.getMacAddress();
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Aggregations

WifiManager (android.net.wifi.WifiManager)169 WifiInfo (android.net.wifi.WifiInfo)53 WifiConfiguration (android.net.wifi.WifiConfiguration)42 IOException (java.io.IOException)24 IntentFilter (android.content.IntentFilter)13 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)10 Context (android.content.Context)9 ConnectivityManager (android.net.ConnectivityManager)8 NetworkInfo (android.net.NetworkInfo)8 Test (org.junit.Test)8 Intent (android.content.Intent)7 File (java.io.File)6 SAXException (org.xml.sax.SAXException)6 SharedPreferences (android.content.SharedPreferences)5 PowerManager (android.os.PowerManager)5 TelephonyManager (android.telephony.TelephonyManager)5 X509Certificate (java.security.cert.X509Certificate)5 BufferedReader (java.io.BufferedReader)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileReader (java.io.FileReader)4