protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); _toastService = Mvx.Resolve<IToastService> (); AnalyticsService = Mvx.Resolve<IAnalyticsService> (); _connectivityManager = (ConnectivityManager)GetSystemService (ConnectivityService); }
public cTestInet(Context c) { m_Contexto = c; m_ConexionINet = false; m_TipoConexion = enumTipoConexion.SINCONEXION; m_NombreConexion = string.Empty; m_VelocidadSubidaReal = 0d; m_VelocidadSubidaTeorica = 0d; m_VelocidadBajadaReal = 0d; m_VelocidadBajadaTeorica = 0d; m_GsmSignalStrengthListener = new GsmSignalStrengthListener(); m_GsmSignalStrengthListener.SignalStrengthChanged += HandleSignalStrengthChanged; m_TelefonoManager = (TelephonyManager) m_Contexto.GetSystemService(Context.TelephonyService); m_TelefonoManager.Listen(m_GsmSignalStrengthListener, PhoneStateListenerFlags.SignalStrengths); m_ConnectivityManager = (ConnectivityManager) m_Contexto.GetSystemService(Context.ConnectivityService); m_WifiManager = (WifiManager) m_Contexto.GetSystemService(Context.WifiService); }
/// <summary> /// Dispose /// </summary> /// <param name="disposing"></param> public override void Dispose(bool disposing) { if (!disposed) { if (disposing) { if (receiver != null) Application.Context.UnregisterReceiver(receiver); ConnectivityChangeBroadcastReceiver.ConnectionChanged = null; if (wifiManager != null) { wifiManager.Dispose(); wifiManager = null; } if (connectivityManager != null) { connectivityManager.Dispose(); connectivityManager = null; } } disposed = true; } base.Dispose(disposing); }
private ConnectionProfile() { NetworkInformation.VerifyNetworkStateAccess(); _connectivityManager = (AndroidConnectivityManager)ContextHelper.Current.GetSystemService(Context.ConnectivityService); if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.LollipopMr1) { var activeNetwork = _connectivityManager.ActiveNetwork; if (activeNetwork != null) { var netCaps = _connectivityManager.GetNetworkCapabilities(activeNetwork); if (netCaps != null) { IsWlanConnectionProfile = netCaps.HasTransport(Android.Net.TransportType.Wifi); IsWwanConnectionProfile = netCaps.HasTransport(Android.Net.TransportType.Cellular); } } } else { #pragma warning disable CS0618 // Type or member is obsolete NetworkInfo info = _connectivityManager.ActiveNetworkInfo; if (info?.IsConnected == true) { IsWwanConnectionProfile = IsConnectionWwan(info.Type); IsWlanConnectionProfile = IsConnectionWlan(info.Type); } #pragma warning restore CS0618 // Type or member is obsolete } }
public override void CheckConnectivity() { Net.ConnectivityManager cm = Application.Context.GetSystemService(Context.ConnectivityService) as Net.ConnectivityManager; Net.NetworkInfo info = cm.ActiveNetworkInfo; NetworkSsid = null; if (info == null) { State = ConnectivityType.Unknown; } else if (info.IsConnectedOrConnecting) { State = (info.Type == Net.ConnectivityType.Wifi) ? ConnectivityType.Wifi : ConnectivityType.Data; if (State == ConnectivityType.Wifi) { string extraInfo = info.ExtraInfo; if (!String.IsNullOrWhiteSpace(extraInfo)) { var tokens = extraInfo.Split('"').Where((item, index) => index % 2 != 0); if (tokens != null) { if (tokens.ToList().Count > 0) { NetworkSsid = tokens.First(); } } } } } else { State = ConnectivityType.None; } }
static NetworkInformation() { #if __ANDROID__ _manager = ConnectivityManager.FromContext(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity); //_manager = ConnectivityManager.FromContext(InTheHand.Platform.Android.ContextManager.Context); #elif __IOS__ || __TVOS__ _reachability = new NetworkReachability("0.0.0.0"); #endif }
private PhoneRequirements CheckInternetRequirements() { _connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); var internetAccess = _connectivityManager.ActiveNetworkInfo; return new PhoneRequirements() { Internet = internetAccess != null && internetAccess.IsConnected }; }
private bool IsNetworkConnected () { if (connectivityManager == null) connectivityManager = (ConnectivityManager)GetSystemService (ConnectivityService); var activeConnection = connectivityManager.ActiveNetworkInfo; if ((activeConnection != null) && activeConnection.IsConnected) return true; else return false; }
private ConnectionProfile() { NetworkInformation.VerifyNetworkStateAccess(); _connectivityManager = (AndroidConnectivityManager)ContextHelper.Current.GetSystemService(Context.ConnectivityService); #pragma warning disable CS0618 // Type or member is obsolete NetworkInfo info = _connectivityManager.ActiveNetworkInfo; if (info?.IsConnected == true) { IsWwanConnectionProfile = IsConnectionWwan(info.Type); IsWlanConnectionProfile = IsConnectionWlan(info.Type); } #pragma warning restore CS0618 // Type or member is obsolete }
//http://www.hasaltaiar.com.au/detecting-network-connectivity-status-changes-on-android-monoforandroid/ //http://developer.xamarin.com/recipes/android/networking/networkinfo/detect_network_connection/ public DeviceNetworkStatus() { //String link = "http://www.google.com"; //URL url = new URL(link); //HttpURLConnection conn = (HttpURLConnection)url.OpenConnection(); //conn.Connect(); //conn.Disconnect(); _connectivity = (ConnectivityManager)Application.Context.GetSystemService(Android.App.Activity.ConnectivityService); _network = new NetworkChangesReceiver(); _network.NetworkStatusChanged += NetworkStatusChanged; Application.Context.RegisterReceiver(_network, new IntentFilter(ConnectivityManager.ConnectivityAction)); }
private PhoneRequirements CheckLocationRequirements() { _locationManager = (LocationManager)GetSystemService(LocationService); _connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); var internetAccess = _connectivityManager.ActiveNetworkInfo; return new PhoneRequirements() { Gps = _locationManager.IsProviderEnabled(LocationManager.GpsProvider), Network = _locationManager.IsProviderEnabled(LocationManager.NetworkProvider), Internet = internetAccess != null && internetAccess.IsConnected }; }
protected override void OnCreate(Bundle bundle) { _bundle = bundle; base.OnCreate(bundle); FrameLayout Layout = new FrameLayout(this); _game = new Game1(); SetContentView(_game.Services.GetService<View>()); Data.Profile.Settings.Identity = (Settings.Secure.GetString(this.ContentResolver, Settings.Secure.AndroidId)); UrlProvider.PackageName = ApplicationContext.PackageName; SwitchToBrowser = false; _game.Run(); NetManager = (ConnectivityManager)GetSystemService(ConnectivityService); BillingServiceConnection = null; }
private async void CallDeleteFriendFromFriendList() { connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService); activeNetworkInfo = connectivityManager.ActiveNetworkInfo; if (activeNetworkInfo == null || !activeNetworkInfo.IsConnected) { Toast.MakeText(this, GetString(Resource.String.NoConnectionInfo), ToastLength.Long).Show(); return; } apiMessage = await DeleteFriendFromFriendList(mItems[(int)info.Id].Id); if (apiMessage.IsSuccessStatusCode) { Toast.MakeText(this, GetString(Resource.String.FriendDeleteOkInfo), ToastLength.Long).Show(); GetMyFriends(); } else if (apiMessage.StatusCode == HttpStatusCode.Unauthorized) { Toast.MakeText(this, GetString(Resource.String.LoginTokenOrTravelerFailure),ToastLength.Long).Show(); Finish(); StartActivity(typeof(LoginActivity)); } else Toast.MakeText(this, GetString(Resource.String.FriendDeleteNotOkInfo), ToastLength.Long).Show(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.eval_system); // Create your application here var textView1 = FindViewById <TextView>(Resource.Id.textView1); Typeface tf = Typeface.CreateFromAsset(Assets, "Font/Tungsten.ttf"); textView1.SetTypeface(tf, TypefaceStyle.Normal); textView1.Text = "ONLINE COMPLIANT MANAGEMENT AND EVALUATION SYSTEM for"; FindViews(); HandleEvents(); Android.Net.ConnectivityManager connectivityManager = (Android.Net.ConnectivityManager)GetSystemService(ConnectivityService); Android.Net.NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo; bool isOnline = (activeConnection != null) && activeConnection.IsConnected; if (isOnline == false) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("No Connection"); alert.SetMessage("Please check your internet connection and try again."); alert.SetButton("OK", (c, ev) => { var activity = (Activity)this; activity.FinishAffinity(); }); alert.Show(); } else { prev = new WebClient().DownloadString("https://jsonblob.com/api/jsonBlob/7367dcc3-c852-11e8-8a99-ad6b1022dc2b"); } }
public AndroidWlanBroadcastReceiver() { _connectivityManager = Application.Context.GetSystemService(global::Android.Content.Context.ConnectivityService) as ConnectivityManager; }
public AndroidReachabilityService(ConnectivityManager connectivityManager) { this._connectivityManager = connectivityManager; //(ConnectivityManager)GetSystemService (ConnectivityService); }
public NetworkPresence (Context context, ConnectivityManager connectivityManager) { this.context = context; this.connectivityManager = connectivityManager; }
public void SetService(AndroidSensusService service) { _service = service; if (_service == null) { if (_connectivityManager != null) _connectivityManager.Dispose(); if (_notificationManager != null) _notificationManager.Dispose(); if (_textToSpeech != null) _textToSpeech.Dispose(); if (_wakeLock != null) _wakeLock.Dispose(); } else { _connectivityManager = _service.GetSystemService(Context.ConnectivityService) as ConnectivityManager; _notificationManager = _service.GetSystemService(Context.NotificationService) as NotificationManager; _textToSpeech = new AndroidTextToSpeech(_service); _wakeLock = (_service.GetSystemService(Context.PowerService) as PowerManager).NewWakeLock(WakeLockFlags.Partial, "SENSUS"); _wakeLockAcquisitionCount = 0; _deviceId = Settings.Secure.GetString(_service.ContentResolver, Settings.Secure.AndroidId); // must initialize after _deviceId is set if (Insights.IsInitialized) Insights.Identify(_deviceId, "Device ID", _deviceId); } }
/// <summary> /// Polls the network state, setting the flags appropriately. /// </summary> private void PollNetworkState() { if (this.connectivityManager == null) { this.connectivityManager = this.GetSystemService(ConnectivityService).JavaCast<ConnectivityManager>(); } if (this.wifiManager == null) { this.wifiManager = this.GetSystemService(WifiService).JavaCast<WifiManager>(); } if (this.connectivityManager == null) { Log.Debug(Tag,"LVLDL couldn't get connectivity manager to poll network state"); } else { NetworkInfo activeInfo = this.connectivityManager.ActiveNetworkInfo; this.UpdateNetworkState(activeInfo); } }
public void SetService(AndroidSensusService service) { _service = service; _connectivityManager = _service.GetSystemService(Context.ConnectivityService) as ConnectivityManager; _notificationManager = _service.GetSystemService(Context.NotificationService) as NotificationManager; _deviceId = Settings.Secure.GetString(_service.ContentResolver, Settings.Secure.AndroidId); _textToSpeech = new AndroidTextToSpeech(_service); _wakeLock = (_service.GetSystemService(Context.PowerService) as PowerManager).NewWakeLock(WakeLockFlags.Partial, "SENSUS"); }
public NetworkConnectionHelperDroid() { _networkHelper = (ConnectivityManager) Application.Context.GetSystemService (Android.Content.Context.ConnectivityService); }
public NetworkService () { connectivityManager = (ConnectivityManager)Application.Context.GetSystemService(Application.ConnectivityService); }
private async void GetMyFriends() { var traveler = JsonConvert.DeserializeObject<Traveler>(preferences.GetString("traveler", null)); connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService); activeNetworkInfo = connectivityManager.ActiveNetworkInfo; if (traveler == null || token == null) { Toast.MakeText(this, GetString(Resource.String.LoginTokenOrTravelerFailure), ToastLength.Long).Show(); Finish(); StartActivity(typeof(LoginActivity)); } else if (activeNetworkInfo == null || !activeNetworkInfo.IsConnected) Toast.MakeText(this, GetString(Resource.String.NoConnectionInfo),ToastLength.Long).Show(); else { var url = string.Format(GetString(Resource.String.ApiLink) + "/api/friendlist/getfriendlist?ownerId={0}", traveler.Id); client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.TokenType, token.AccessToken); var loadingMessage = ProgressDialog.Show(this, GetString(Resource.String.LoadingFriendListTitle), GetString(Resource.String.LoadingFriendListContent), true, false); var response = await client.GetAsync(new Uri(url)); loadingMessage.Dismiss(); mItems.Clear(); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); var friendListItems = JsonConvert.DeserializeObject<List<FriendListItem>>(content); foreach (var friendListItem in friendListItems) { mItems.Add(new FriendListItem { Id = friendListItem.Id, OwnerId = friendListItem.OwnerId, FriendId = friendListItem.FriendId, Owner = friendListItem.Owner, Friend = friendListItem.Friend }); } } else if (response.StatusCode == HttpStatusCode.NotFound) Toast.MakeText(this, GetString(Resource.String.LoadingFriendListEmptyInfo), ToastLength.Long).Show(); else Toast.MakeText(this, GetString(Resource.String.LoadingFriendListNotOkInfo), ToastLength.Long).Show(); var adapter = new MyFriendsListViewAdapter(this, mItems); mMyFriendsList.Adapter = adapter; } }
protected override void OnCreate (Bundle bundle) { base.OnCreate(bundle); connectivityManager = GetSystemService(ConnectivityService) as ConnectivityManager; locationManager = GetSystemService(LocationService) as LocationManager; var mobileState = connectivityManager.GetNetworkInfo(ConnectivityType.Wifi).GetState(); provider = LocationManager.NetworkProvider; locationManager = (LocationManager)GetSystemService(LocationService); if (mobileState == NetworkInfo.State.Disconnected) { // We are connected via WiFi AlertDialog.Builder wifiError = new AlertDialog.Builder (this); AlertDialog wifiAlert = wifiError.Create (); wifiAlert.SetTitle ("Error Connection"); wifiAlert.SetMessage ("There is no wifi connection!Please connect to wifi and try again!App now will close!"); wifiAlert.SetButton ("Ok", delegate { wifiAlert.Dismiss (); System.Environment.Exit (0); }); } else if (!locationManager.IsProviderEnabled (provider)) { AlertDialog.Builder gpsError = new AlertDialog.Builder (this); AlertDialog gpsAlert = gpsError.Create (); gpsAlert.SetTitle ("Error Connection"); gpsAlert.SetMessage ("There is no wifi connection!Please connect to wifi and try again!App now will close!"); gpsAlert.SetButton ("Ok", delegate { gpsAlert.Dismiss (); System.Environment.Exit (0); }); } else { ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; ActionBar.SetDisplayShowHomeEnabled (false); ActionBar.SetDisplayShowTitleEnabled (false); SetContentView(Resource.Layout.Main); locationText = FindViewById<TextView>(Resource.Id.location); locationText.Text = "Please wait until we find you with our spy devices :)"; addressText = String.Empty; home = new HomeFragment (); search = new SearchFragment (); mCurrentFragment = home; mStackFragments = new Stack<Fragment>(); var homeTab = ActionBar.NewTab(); homeTab.SetText(Resources.GetString(Resource.String.tab1_text)); homeTab.SetIcon(Resource.Drawable.home_icon); homeTab.SetTabListener (this); ActionBar.AddTab(homeTab); var searchTab = ActionBar.NewTab(); searchTab.SetText(Resources.GetString(Resource.String.tab2_text)); searchTab.SetIcon(Resource.Drawable.search_icon); searchTab.SetTabListener (this); ActionBar.AddTab(searchTab); var trans = FragmentManager.BeginTransaction (); trans.Add (Resource.Id.fragmentContainer, home, "Home"); trans.Add (Resource.Id.fragmentContainer, search, "Search"); trans.Hide (search); trans.Commit (); InitializeLocationManager (); } }