private void OpenInAppPurchasePopUp() { WifiManager wifiManager = (WifiManager)GetSystemService(Context.WifiService); WifiInfo wInfo = wifiManager.ConnectionInfo; String MACAdress = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetMessage("To access this feature you will need to make a purchase of $1.99 for the lifetime use on this device. Would you like to continue and purchase this add-on?"); builder.SetCancelable(false); builder.SetPositiveButton("Yes", (object sender, DialogClickEventArgs e) => { try { _serviceConnection.BillingHandler.BuyProduct(_products[0]); } catch (Exception ex) { } }); builder.SetNegativeButton("No", (object sender, DialogClickEventArgs e) => { }); AlertDialog alertdialog = builder.Create(); alertdialog.Show(); }
private Stripe.Token CreateToken(string item, string email) { try { GeneralValues objGeneralValues = new GeneralValues(); string plan = item.Split(new String[] { "|||" }, StringSplitOptions.None)[0].ToString(); WifiManager wifiManager = (WifiManager)GetSystemService(Context.WifiService); WifiInfo wInfo = wifiManager.ConnectionInfo; String MACAdress = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); string amount = item.Split(new String[] { "|||" }, StringSplitOptions.None)[1].ToString(); string id = item.Split(new String[] { "|||" }, StringSplitOptions.None)[2].ToString(); string planid = id; decimal PaymentAmount = Convert.ToDecimal(amount); Dialog paymentdialog = new Dialog(this); paymentdialog.RequestWindowFeature((int)WindowFeatures.NoTitle); paymentdialog.SetContentView(Resource.Layout.Payment); paymentdialog.SetCanceledOnTouchOutside(false); Typeface tf = Typeface.CreateFromAsset(Assets, "Fonts/ROBOTO-LIGHT.TTF"); string encryptedplanname = URLEncoder.Encode(Encrypt(plan), "UTF-8"); string encryptedamount = URLEncoder.Encode(Encrypt(amount), "UTF-8"); string encryptedplanid = URLEncoder.Encode(Encrypt(planid), "UTF-8"); string encrypteduserid = URLEncoder.Encode(Encrypt(empid.ToString()), "UTF-8"); string encryptedmacadress = URLEncoder.Encode(Encrypt(MACAdress), "UTF-8"); string encryptedemailaddress = URLEncoder.Encode(Encrypt(email), "UTF-8"); string url = objGeneralValues.PaymentURL + "?planname=" + encryptedplanname + "&amount=" + encryptedamount + "&planid=" + encryptedplanid + "&user="******"&macaddress=" + encryptedmacadress + "&email=" + encryptedemailaddress; Intent browserintent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("http://59.162.181.91/dtswork/ImInventoryWebPayment/default.aspx?planname=" + encryptedplanname + "&amount=" + encryptedamount + "&planid=" + encryptedplanid + "&user="******"&macaddress=" + encryptedmacadress + "&email=" + encryptedemailaddress)); selecteditempositin = 0; StartActivity(browserintent); } catch (Exception ex) { } return(new Stripe.Token()); }
private void OnUiInfo(object sender, EventArgs e) { if (this.selectedWifi != null) { WifiInfo.ShowBox(this, this.selectedWifi); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { try { _serviceConnection.BillingHandler.HandleActivityResult(requestCode, resultCode, data); WifiManager wifiManager = (WifiManager)GetSystemService(Context.WifiService); WifiInfo wInfo = wifiManager.ConnectionInfo; String MACAdress = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); //TODO: Use a call back to update the purchased items UpdatePurchasedItems(); if (resultCode == Result.Ok) { WebService objWebService = new WebService(); objWebService.ExternalSignUpUserSubscriptionAsync(empid.ToString(), MACAdress, AccessFindITExport, "1", AccessExport); // objWebService.GetEmpDetailsByEmpIDAsync(empid.ToString(), MACAdress); //objWebService.GetEmpDetailsByEmpIDCompleted += getempxml; objWebService.ExternalSignUpUserSubscriptionCompleted += getExternalSignUpUserSubscriptionxml; // long sizetoupload = -102400 + Convert.ToInt64(UploadedSize); // objWebService.FreeUserUploadSizeUpdateAsync(empid.ToString(), MACAdress, sizetoupload.ToString()); } else { WebService objWebService = new WebService(); objWebService.ExternalSignUpUserSubscriptionAsync(empid.ToString(), MACAdress, AccessFindITExport, "0", AccessExport); // objWebService.GetEmpDetailsByEmpIDAsync(empid.ToString(), MACAdress); //objWebService.GetEmpDetailsByEmpIDCompleted += getempxml; objWebService.ExternalSignUpUserSubscriptionCompleted += getExternalSignUpUserSubscriptionxml; } } catch { } }
/*コンストラクタ*/ //public void Sample_WifiConnection(Context context) //{ // wifi = (WifiManager)context.GetSystemService(Context.WifiService); //} //IPアドレスの取得 string getIpAddress() { WifiConfiguration wifiConfig = new WifiConfiguration(); wifi = (WifiManager)Application.Context.GetSystemService(Context.WifiService); WifiInfo wifiinfo = (WifiInfo)Application.Context.GetSystemService(Context.WifiService); //int netId = WifiManager.addNetwork(wifiConfig); wifi.Disconnect(); //wifi.EnableNetwork(netId, true); wifi.Reconnect(); int iPAddress = wifiinfo.IpAddress; //return iPAddress; int ipAddress_int = wifi.ConnectionInfo.IpAddress; if (ipAddress_int == 0) { ipAddress = null; } else { ipAddress = (ipAddress_int & 0xFF) + "." + (ipAddress_int >> 8 & 0xFF) + "." + (ipAddress_int >> 16 & 0xFF) + "." + (ipAddress_int >> 24 & 0xFF); } return(ipAddress); }
public string GetCurrentWifiSSID() { var ssid = string.Empty; if (_connectivityManager != null && _wifiManager != null) { NetworkInfo networkInfo = _connectivityManager.ActiveNetworkInfo; if (networkInfo?.IsConnected ?? false) { WifiInfo connectionInfo = _wifiManager.ConnectionInfo; if (connectionInfo != null) { ssid = connectionInfo.SSID; Debug.WriteLine("获取到当前的SSID:" + ssid); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1 && ssid.StartsWith("\"") && ssid.EndsWith("\"")) { ssid = Regex.Replace(ssid, "^\"|\"$", ""); } } } } return(ssid); }
/// <summary> /// Return dynamic information about the current Wi-Fi connection, if any is active. /// </summary> /// <returns> the Wi-Fi information, contained in WifiInfo.</returns> public static WifiInfo GetWifiConnectionInfo() { if (AGUtils.IsNotAndroidCheck()) { return(null); } using (var wifiInfoAJO = GetWifiInfoAJO()) { if (wifiInfoAJO == null) { return(null); } var result = new WifiInfo { BSSID = wifiInfoAJO.CallStr("getBSSID"), SSID = wifiInfoAJO.CallStr("getSSID"), MacAddress = wifiInfoAJO.CallStr("getMacAddress"), LinkSpeed = wifiInfoAJO.CallInt("getLinkSpeed"), NetworkId = wifiInfoAJO.CallInt("getNetworkId"), IpAddress = wifiInfoAJO.CallInt("getIpAddress"), Rssi = wifiInfoAJO.CallInt("getRssi") }; return(result); } }
static void Main(string[] args) { List <WifiInfo> WifiInfoList = new List <WifiInfo>(); WifiInfo wifiInfo; string readPath = @"D:\Projects\Wifi Measurements\J200_0,3.txt"; //string readPath = @"D:\Projects\test.txt"; string writePath = @"D:\Projects\AVG Wifi Measurements\J200_0,3AVG.txt"; int IterCount = 0; StreamReader sr = new StreamReader(readPath, System.Text.Encoding.Default); string[] rawMass = sr.ReadToEnd().Split("\n"); sr.Close(); foreach (string CurrRawMass in rawMass) { if (CurrRawMass != null) { if (CurrRawMass.Split('#').Length != 1) { wifiInfo = new WifiInfo(); wifiInfo.SSID = CurrRawMass.Split("#")[0]; wifiInfo.BSSID = CurrRawMass.Split("#")[1]; wifiInfo.level = CurrRawMass.Split("#")[2]; if (wifiInfo.BSSID != "") { if (!WifiInfoList.Exists(x => x.BSSID == wifiInfo.BSSID)) { wifiInfo.avglevel = Double.Parse(wifiInfo.level.Split("dBm")[0]); wifiInfo.NumBerOfMentions = 1; WifiInfoList.Add(wifiInfo); } else { WifiInfoList.Find(x => x.BSSID.Contains(wifiInfo.BSSID)).avglevel += Convert.ToDouble(wifiInfo.level.Split("dBm")[0]); WifiInfoList.Find(x => x.BSSID.Contains(wifiInfo.BSSID)).NumBerOfMentions++; } } } else { IterCount++; } } } Console.WriteLine(IterCount); Console.WriteLine(WifiInfoList.Count); StreamWriter sw = new StreamWriter(writePath, false, System.Text.Encoding.Default); foreach (WifiInfo WI in WifiInfoList) { if (WI.NumBerOfMentions > IterCount / 2) { Console.WriteLine(WI.SSID + " " + WI.BSSID + " " + Math.Round(WI.avglevel / WI.NumBerOfMentions, 1) + " " + WI.NumBerOfMentions); //sw.WriteLine(WI.SSID + "#" + Math.Round(WI.avglevel / WI.NumBerOfMentions,1) + "dBm#" + WI.NumBerOfMentions); sw.WriteLine(WI.SSID + "#" + WI.BSSID + "#" + Math.Round(WI.avglevel / WI.NumBerOfMentions, 1) + "dBm#" + WI.NumBerOfMentions); } } sw.Close(); Console.Read(); }
public string GetIpAddress() { var wifiManager = WifiManager.FromContext(Application.Context); WifiInfo info = wifiManager.ConnectionInfo; return(wifiManager.IsWifiEnabled ? new IPAddress(info.IpAddress).ToString() : null); }
public int GetWifiSpeed() { var wifiManager = WifiManager.FromContext(Application.Context); WifiInfo info = wifiManager.ConnectionInfo; return(info.LinkSpeed); }
public string GetSSID() { WifiManager wifiManager = (WifiManager)Android.App.Application.Context.GetSystemService(Context.WifiService); WifiInfo wifiInfo = wifiManager.ConnectionInfo; return(wifiInfo.SSID); }
/** * 获取当前连接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); }
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; }
/** * 获取 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); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { CaptivePortalDetector.DefaultDetectionMethod = SettingsService.Instance.DetectionMethod; _currentSsid = await WifiInfo.GetSsid(); _profile = ProfilesService.Instance.ProfilesDbCollection.FindOne(x => x.Ssid == _currentSsid); _checkConnectTimer.Start(); UpdateButtonStates(); }
//funcion que me devuelve la velocidad del enlace wifi public int getLinkSpeed(Context context) { int linkSpeed = 0; WifiManager wifiManager = (WifiManager)context.GetSystemService(Context.WifiService); WifiInfo wifiInfo = wifiManager.ConnectionInfo; if (wifiInfo != null) { linkSpeed = wifiInfo.LinkSpeed; } return(linkSpeed); }
public int GetStrength() { Context _context = Android.App.Application.Context; //Xamarin.Forms.Forms.Context //WifiManager wifiManager = (WifiManager)Forms.Context.GetSystemService(Context.WifiService); WifiManager wifiManager = (WifiManager)_context.GetSystemService(Context.WifiService); int numberOfLevels = 5; WifiInfo wifiInfo = wifiManager.ConnectionInfo; int level = WifiManager.CalculateSignalLevel(wifiInfo.Rssi, numberOfLevels); return(level); }
public void disconnect() { if (_wifiManager != null) { // Return dynamic information about the current Wi-Fi connection, if any is active. WifiInfo wifiInfo = _wifiManager.ConnectionInfo; if (wifiInfo != null) { _wifiManager.Disconnect(); } } }
private string GetSSIDName() { ConnectivityManager connectivityManager = (ConnectivityManager)Android.App.Application.Context.GetSystemService(Context.ConnectivityService); NetworkInfo networkInfo = connectivityManager.ActiveNetworkInfo; if (networkInfo != null && networkInfo.IsConnected) { WifiManager wifiManager = (WifiManager)(Android.App.Application.Context.GetSystemService(Context.WifiService)); WifiInfo wifiInfo = wifiManager.ConnectionInfo; return(wifiInfo != null && !string.IsNullOrEmpty(wifiInfo.SSID) ? wifiInfo.SSID : string.Empty); } return(string.Empty); }
public void WifiInfo() { WifiManager wifiManager = (WifiManager)(Application.Context.GetSystemService(Context.WifiService)); WifiInfo wifiinfo = wifiManager.ConnectionInfo; bssid = wifiinfo.BSSID; ssid = wifiinfo.SSID; rssi = wifiinfo.Rssi; linkspeed = wifiinfo.LinkSpeed; int freq = (wifiinfo.Frequency); frequency = freq / 1000f; ip1 = Dns.GetHostAddresses(Dns.GetHostName()); }
public string GetCurrentSSID() { WifiManager wifiManager = (WifiManager)Xamarin.Forms.Forms.Context.GetSystemService(Context.WifiService); WifiInfo wifiInfo = wifiManager.ConnectionInfo; if (wifiInfo != null) { return(wifiInfo.SSID); } else { return(null); } }
/** * 获取当前连接wifi的名称 * * @return */ public static String getConnectWifiIp(Context context) { if (isWifiConnected(context)) { WifiManager wifiManager = (WifiManager)context.GetSystemService(Context.WifiService); WifiInfo wifiInfo = wifiManager.ConnectionInfo; int ipAddress = wifiInfo.IpAddress; if (ipAddress == 0) { return(null); } return((ipAddress & 0xff) + "." + (ipAddress >> 8 & 0xff) + "." + (ipAddress >> 16 & 0xff) + "." + (ipAddress >> 24 & 0xff)); } return(null); }
/// <summary> /// Connect to wifi using ssid and password /// </summary> /// <param name="_ssid"></param> /// <param name="_pwd"></param> /// <returns></returns> public async Task <bool> Connect(string _ssid, string _pwd) { //return true; Connect1(_ssid, _pwd); string ssid = ""; string pwd = ""; ssid = $"\"{_ssid}\""; pwd = $"\"{_pwd}\""; DateTime timeSpan = DateTime.Now; WifiInfo _network = null; while (true) { string msg = wifiManager.ConnectionInfo?.SSID; mobileHelper.Log("2st while: " + msg); System.Diagnostics.Debug.WriteLine(msg); _network = wifiManager.ConnectionInfo; //Thread.Sleep(1000); await Task.Delay(1 * 1000); if (_network.SupplicantState == SupplicantState.Completed && _network.SSID == ssid) { break; } else if (DateTime.Now.Subtract(timeSpan).TotalSeconds < 20) { continue; } else { _network = null; break; } } //await Task.Delay(2 * 1000); if (_network == null) { System.Diagnostics.Debug.WriteLine("ConnectionInfo:" + wifiManager.ConnectionInfo?.SSID); mobileHelper.Log("_network false:" + wifiManager.ConnectionInfo?.SSID); return(false); } mobileHelper.Log("_network true:" + wifiManager.ConnectionInfo?.SSID); return(true); }
private Stripe.Token CreateToken(string item) { try { GeneralValues objGeneralValues = new GeneralValues(); WebService objWebService = new WebService(); EditText txtemail = FindViewById <EditText>(Resource.Id.txtSignUpEmail); string email = txtemail.Text; plan = item.Split(new String[] { "|||" }, StringSplitOptions.None)[0].ToString(); WifiManager wifiManager = (WifiManager)GetSystemService(Context.WifiService); WifiInfo wInfo = wifiManager.ConnectionInfo; String MACAdress = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); string amount = item.Split(new String[] { "|||" }, StringSplitOptions.None)[1].ToString(); string id = item.Split(new String[] { "|||" }, StringSplitOptions.None)[2].ToString(); planid = id; PaymentAmount = Convert.ToDecimal(amount); RadioButton rdbBusinessUse = FindViewById <RadioButton>(Resource.Id.rdbBusinessUse); Dialog paymentdialog = new Dialog(this); paymentdialog.RequestWindowFeature((int)WindowFeatures.NoTitle); paymentdialog.SetContentView(Resource.Layout.Payment); paymentdialog.SetCanceledOnTouchOutside(false); Typeface tf = Typeface.CreateFromAsset(Assets, "Fonts/ROBOTO-LIGHT.TTF"); string encryptedplanname = URLEncoder.Encode(Encrypt(plan), "UTF-8"); string encryptedamount = URLEncoder.Encode(Encrypt(amount), "UTF-8"); string encryptedplanid = URLEncoder.Encode(Encrypt(planid), "UTF-8"); string encrypteduserid = URLEncoder.Encode(Encrypt(userid), "UTF-8"); string encryptedmacadress = URLEncoder.Encode(Encrypt(MACAdress), "UTF-8"); string encryptedemailaddress = URLEncoder.Encode(Encrypt(email), "UTF-8"); string url = objGeneralValues.PaymentURL + "?planname=" + encryptedplanname + "&amount=" + encryptedamount + "&planid=" + encryptedplanid + "&user="******"&macaddress=" + encryptedmacadress + "&email=" + encryptedemailaddress; Intent browserintent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(objGeneralValues.PaymentURL + "?planname=" + encryptedplanname + "&amount=" + encryptedamount + "&planid=" + encryptedplanid + "&user="******"&macaddress=" + encryptedmacadress + "&email=" + encryptedemailaddress)); selecteditempositin = 0; if (plan.Trim().ToLower().Contains("platinum")) { objWebService.ExternalSignUpUserSubscriptionAsync(EmployeeID.ToString(), MACAdress, "1", "1", "1"); } else { objWebService.ExternalSignUpUserSubscriptionAsync(EmployeeID.ToString(), MACAdress, "0", "0", "0"); } StartActivity(browserintent); } catch (Exception ex) { } return(token); }
public void ScanDeviceThread() { int BEGANNum = 0; //开始扫描的起始 int ENDNum = 0; //开始扫描的结束 int mTheardNum; lock (this) { mTheardNum = TheardNum++;//当前是第几个线程 } BEGANNum = mTheardNum * 256 / ScanDeviceTheardNum; ENDNum = BEGANNum + 256 / ScanDeviceTheardNum; ConnectivityManager cm = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService); NetworkInfo activeNetwork = cm.ActiveNetworkInfo; WifiManager wm = (WifiManager)context.GetSystemService(Context.WifiService); WifiInfo connectionInfo = wm.ConnectionInfo; int ipAddress = connectionInfo.IpAddress; string ipString = Formatter.FormatIpAddress(ipAddress); string prefix = ipString.Substring(0, ipString.LastIndexOf(".") + 1); for (int i = BEGANNum; i < ENDNum; i++)//执行扫描 { string testIp = prefix + i.ToString(); InetAddress address = InetAddress.GetByName(testIp); bool reachable = address.IsReachable(800); string hostName = address.CanonicalHostName; if (reachable)//如果Ping通 吧IP加入 { lock (this) { DeviceIP.Add(testIp, ""); } } } TheardComplete++; //线程完成数加1 if (TheardComplete >= ScanDeviceTheardNum) //如果这个是最后一个完成的线程 { Log.Info("TCP", "StartConnectDevice : " + DeviceIP.Count.ToString()); TheardComplete = 0; TheardNum = 0; ConnectDevice();//开始尝试连接 } }
public static String GetMacAdress(Context context) { String macAddress = String.Empty; try { WifiManager wifiManager = (WifiManager)context.GetSystemService(Context.WifiService); WifiInfo wInfo = wifiManager.ConnectionInfo; macAddress = wInfo.MacAddress; } catch { macAddress = String.Empty; } return(macAddress); }
private async void GetProfileNameButton_Click(object sender, RoutedEventArgs e) { var ssid = await WifiInfo.GetSsid(); if (!string.IsNullOrEmpty(ssid)) { ViewModel.SelectedProfile.Ssid = ssid; } else { var noWifiDialog = new ContentDialog { Title = "No WiFi connected", Content = "Cannot get current WiFi network's SSID.", PrimaryButtonText = "Ok" }; await noWifiDialog.ShowAsync(); } }
private string GetCurrentSSID() { string ssid = ""; WifiManager wifiManager = (WifiManager)(Application.Context.GetSystemService(Android.Content.Context.WifiService)); WifiInfo info = wifiManager.ConnectionInfo; int networkId = info.NetworkId; IList <WifiConfiguration> netConfList = wifiManager.ConfiguredNetworks; foreach (WifiConfiguration wificonf in netConfList) { if (wificonf.NetworkId == networkId) { ssid = wificonf.Ssid.Replace("\"", ""); break; } } return(ssid); }