/// <summary> /// On create simply detect some of our managers /// </summary> public override void OnCreate() { base.OnCreate(); //Find our audio and notificaton managers audioManager = (AudioManager)GetSystemService(AudioService); wifiManager = (WifiManager)GetSystemService(WifiService); remoteComponentName = new ComponentName(PackageName, new RemoteControlBroadcastReceiver().ComponentName); }
public Wifi() { Mvx.CallbackWhenRegistered <IMvxAndroidGlobals>(x => { _manager = x.ApplicationContext.GetSystemService(Context.WifiService) .JavaCast <WifiManager>(); }); }
public static void Register() { wifi = (WifiManager)Android.App.Application.Context.GetSystemService(Context.WifiService); // Start a scan and register the Broadcast receiver to get the list of Wifi Networks wifiReceiver = new WifiReceiver(); Android.App.Application.Context.RegisterReceiver(wifiReceiver, new IntentFilter(WifiManager.ScanResultsAvailableAction)); wifi.StartScan(); }
public async Task <string> GetWifiMacAddress() { string res = null; PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync <LocationPermission>(); if (status != PermissionStatus.Granted) { status = await CrossPermissions.Current.RequestPermissionAsync <LocationPermission>(); } if (status == PermissionStatus.Granted) { WifiManager wifiManager = (WifiManager)(Application.Context.GetSystemService(Context.WifiService)); res = wifiManager.ConnectionInfo.MacAddress; string macAddress = string.Empty; var all = Collections.List(Java.Net.NetworkInterface.NetworkInterfaces); foreach (var interfaces in all) { if (!(interfaces as Java.Net.NetworkInterface).Name.Contains("wlan0")) { continue; } var macBytes = (interfaces as Java.Net.NetworkInterface).GetHardwareAddress(); if (macBytes == null) { continue; } var sb = new System.Text.StringBuilder(); foreach (var b in macBytes) { string convertedByte = string.Empty; convertedByte = (b & 0xFF).ToString("X2") + ":"; if (convertedByte.Length == 1) { convertedByte.Insert(0, "0"); } sb.Append(convertedByte); } macAddress = sb.ToString().Remove(sb.Length - 1); return(macAddress); } return("02:00:00:00:00:00"); } return(res); }
public override void OnReceive(Context context, Intent intent) { // if wifi has been disabled then don't retrieve the results WifiManager wifi = (WifiManager)context.GetSystemService(Context.WifiService); if (!wifi.IsWifiEnabled) { return; } var scanWiFiNetworks = wifi.ScanResults; foreach (ScanResult wifinetwork in scanWiFiNetworks) { var network = new WiFiNetwork() { BSSID = wifinetwork.Bssid, SSID = wifinetwork.Ssid, Frequency = wifinetwork.Frequency, Capabilities = wifinetwork.Capabilities, //TimeStamp = DateTimeOffset.FromFileTime(wifinetwork.Timestamp) TimeStamp = DateTimeOffset.Now, Location = wiFiLocation, Address = wiFiAddress }; // calculate the signal int level = WifiManager.CalculateSignalLevel(wifi.ConnectionInfo.Rssi, wifinetwork.Level); int difference = level * 100 / wifinetwork.Level; int signalStrength = 0; if (difference >= 100) { network.SignalStrength = 4; } else if (difference >= 75) { network.SignalStrength = 3; } else if (difference >= 50) { network.SignalStrength = 2; } else if (difference >= 25) { network.SignalStrength = 1; } if (!wiFiNetworks.Exists(n => n.SSID == network.SSID && n.BSSID == network.BSSID)) { wiFiNetworks.Add(network); } } thisActivity.UpdateList(); }
public NetworkService(NetworkConfigurationDroid configuration) { BaseUrl = configuration.BaseUrl; _Manager = (ConnectivityManager)Application.Context.GetSystemService(Application.ConnectivityService); _WifiManager = (WifiManager)Application.Context.GetSystemService(Application.WifiService); Configuration = configuration; Init(); }
private void AttachCallbacksAndIDs() { textMessage = FindViewById <TextView>(Resource.Id.message); wifiManager = (WifiManager)ApplicationContext.GetSystemService(Context.WifiService); buttonCreateHotspot = FindViewById <Button>(Resource.Id.hotspotBtn); buttonSendMessage = FindViewById <Button>(Resource.Id.SendMessageButton); buttonCreateHotspot.Click += OnCreateNetworkButtonClick; buttonSendMessage.Click += OnMessageSendButtonClick; LocalHotspot.StateChange += OnHotspotStateChange; }
public Wifi() { Mvx.IoCProvider.CallbackWhenRegistered <IMvxAndroidGlobals>(() => { var globals = Mvx.IoCProvider.Resolve <IMvxAndroidGlobals>(); _manager = globals.ApplicationContext.GetSystemService(Context.WifiService) .JavaCast <WifiManager>(); }); }
/// <summary> /// Включение Wi-Fi /// </summary> private void TurnOnWiFi() { WifiManager wifiManager = (WifiManager)Android.App.Application.Context.GetSystemService(Context.WifiService); if (!wifiManager.IsWifiEnabled) { // Active Wi-Fi connection. wifiManager.SetWifiEnabled(true); } }
void getExternalSignUpUserSubscriptionxml(object sender, ExternalSignUpUserSubscriptionCompletedEventArgs e) { WifiManager wifiManager = (WifiManager)GetSystemService(Context.WifiService); WifiInfo wInfo = wifiManager.ConnectionInfo; String MACAdress = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); WebService objWebService = new WebService(); objWebService.GetEmpDetailsByEmpIDAsync(empid.ToString(), MACAdress); objWebService.GetEmpDetailsByEmpIDCompleted += getempxml; }
public CustomNetworkCallback(WifiManager wifiManager, Action startLocationUpdates, Action stopLocationUpdates) { _wifiManager = wifiManager; _startLocationUpdates = startLocationUpdates; _stopLocationUpdates = stopLocationUpdates; _networkLogService = new NetworkLogService(); _settingsService = new SettingsService(); IsConnected = false; }
public WifiReceiver(WifiManager wifiManager, Android.Widget.ListView wifiDeviceList, Context context, EditText pass, Button connectButton) { _wifiManager = wifiManager; _wifiDeviceListView = wifiDeviceList; _context = context; _password = pass; _connectButton = connectButton; AttachCallbacks(); ShowButtonConnectState(true, true); }
public TestAppWifiService() { WifiNetworks = new ObservableCollection <IWifiNetwork>(); var wifiMonitor = new WifiMonitor(); wifiMonitor.OnNetworkDetected += WifiMonitor_OnNetworkDetected; Application.Context.RegisterReceiver(wifiMonitor, new IntentFilter(WifiManager.ScanResultsAvailableAction)); _wifiManager = ((WifiManager)Application.Context.GetSystemService(Context.WifiService)); }
public WifiReceiver(WifiManager wifi) { this.wifi = wifi; wifiNetworks = new List <string>(); wiFiInfos = new List <WiFiInfo>(); receiverARE = new AutoResetEvent(false); //connectedSSID = ((WifiManager)wifi).ConnectionInfo.SSID.Replace("\"",""); connectedSSID = ((WifiManager)wifi).ConnectionInfo.BSSID; }
/** * 获取 MAC 地址 * 须配置android.permission.ACCESS_WIFI_STATE权限 */ public static string getMacAddress(Context context) { //wifi mac地址 WifiManager wifi = (WifiManager)context.GetSystemService(Context.WifiService); WifiInfo info = wifi.ConnectionInfo; string mac = info.MacAddress; LogUtils.i(TAG, " MAC:" + mac); return(mac); }
/** * 获取当前连接wifi的名称 * * @return */ public static String getConnectWifiSsid(Context context) { if (isWifiConnected(context)) { WifiManager wifiManager = (WifiManager)context.GetSystemService(Context.WifiService); WifiInfo wifiInfo = wifiManager.ConnectionInfo; return(wifiInfo.SSID); } return(null); }
public override void OnReceive(Context context, Intent intent) { var mainActivity = (MainActivity)context; string action = intent.Action; if (action == WifiManager.ScanResultsAvailableAction) { WifiManager wifiManager = (WifiManager)Android.App.Application.Context.GetSystemService(Android.Content.Context.WifiService); IList <ScanResult> scanResults = wifiManager.ScanResults; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); wifi = (WifiManager)ApplicationContext.GetSystemService(Context.WifiService); mlock = wifi.CreateMulticastLock("Zeroconf lock"); mlock.Acquire(); SetPage(App.GetMainPage()); }
public string GetSSID() { string wifi = "Desconocida (Android)"; WifiManager wifiManager = (WifiManager)(Application.Context.GetSystemService(Context.WifiService)); if (wifiManager != null) { wifi = wifiManager.ConnectionInfo.SSID; } return(wifi); }
private bool IsConnectedToWifi() { WifiManager wifiManager = (WifiManager)Activity.GetSystemService(Context.WifiService); if (wifiManager.IsWifiEnabled && wifiManager.ConnectionInfo?.NetworkId != -1) { return(true); } return(false); }
public RadioStationServiceLock(Context context) { _wifiManager = (WifiManager)context.GetSystemService(Context.WifiService); _powerManager = (PowerManager)context.GetSystemService(Context.PowerService); _wifiLock = _wifiManager.CreateWifiLock(WifiMode.Full, "wzxv.app"); _wifiLock.Acquire(); _powerWakeLock = _powerManager.NewWakeLock(WakeLockFlags.Partial, "wzxv.app"); _powerWakeLock.Acquire(); }
public override void OnReceive(Context context, Intent intent) { IList <ScanResult> scanResults = new List <ScanResult>(); WifiManager manager = (WifiManager)context.GetSystemService(Context.WifiService); foreach (var result in manager.ScanResults) { scanResults.Add(result); } this.onSuccess.Invoke(scanResults); }
public void getDatosRedWifi() { //OBTENER DATOS WIFI O LOCAL WifiManager wifiManager = (WifiManager)Application.Context.GetSystemService(Service.WifiService); ip = wifiManager.ConnectionInfo.IpAddress; SSID = wifiManager.ConnectionInfo.SSID.Replace('"', ' ').Trim(); conexionWifi = wifiManager.IsWifiEnabled; // Toast.MakeText(this, "Conexión Wifi: " + conexionWifi + " IP: " + ip + " SSID: " + SSID, ToastLength.Short).Show(); //FIN OBTENER WIFI O LACAL }
public NetworkService(NetworkConfigurationDroid configuration) { BaseUrl = configuration.BaseUrl; _Manager = (ConnectivityManager)Application.Context.GetSystemService(Application.ConnectivityService); _WifiManager = (WifiManager)Application.Context.GetSystemService(Application.WifiService); _Configuration = configuration; //_Globals = Mvx.Resolve<IMvxAndroidGlobals>(); Init(); }
private string GetAccessPointBSSID() { string accessPointBSSID = null; if (SensusServiceHelper.Get().WiFiConnected) { WifiManager wifiManager = Application.Context.GetSystemService(global::Android.Content.Context.WifiService) as WifiManager; accessPointBSSID = wifiManager.ConnectionInfo.BSSID; } return(accessPointBSSID); }
public static string WifiBSSID() { try { WifiManager wifiManager = (WifiManager)Application.Context.GetSystemService(Context.WifiService); return(wifiManager.ConnectionInfo.BSSID); } catch (Exception ex) { return(null); } }
private string GetAccessPointBSSID() { string accessPointBSSID = null; if (_connectivityManager.GetNetworkInfo(ConnectivityType.Wifi).IsConnected) { WifiManager wifiManager = Application.Context.GetSystemService(global::Android.Content.Context.WifiService) as WifiManager; accessPointBSSID = wifiManager.ConnectionInfo.BSSID; } return(accessPointBSSID); }
private void _remove(string ssid, WifiManager wifi) { List <WifiConfiguration> existing = wifi.ConfiguredNetworks.Where(w => w.Ssid == "\"" + ssid + "\"").ToList <WifiConfiguration>(); if (existing.Count() > 0) { foreach (WifiConfiguration config in existing) { wifi.RemoveNetwork(config.NetworkId); } } }
public AndroidWifiConnector() { try { _wifiManager = (WifiManager)Android.App.Application.Context .GetSystemService(Context.WifiService); } catch (Exception ex) { OnError?.Invoke(new Exception("WifiConnector can not access the device WifiManager", ex)); } }
public static void InitWifiScan(Context ctx) { try { myWifiManager = (WifiManager)ctx.GetSystemService(Context.WifiService); myWifiReceiver = new WifiReceiver(); } catch (Exception ex) { AndroidLevelLogger.e(TAG, ex); } }