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();
}
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);
}
}
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";
}
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;
}
}
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();
}
Aggregations