title: How to get the user location based on mobile sim network in android in c#"?
body: <p>I want to get the user's current location (latitude and longitude) always using Sim-based network only, not by using any other networks (like WiFi, Mobile Data, GPS and other Network and even all these are in Disabled mode in mobile). Not necessarily exact location but even approximate location. </p>
  
  <p>Is there any possibility to get it? If any of you can explain and include code; I searched in Google but did not get the correct related answer.</p>
  
  <pre><code>using Android.App;
  using Android.Content;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  using Android.OS;
  using Android.Locations;
  using Android.Util;
  using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Linq;
  using System.Xml.Linq;
  using System.Threading;
  
  
  
  
  namespace GPS_Android
  {
      [Activity(Label = "GPS_Android", MainLauncher = true, Icon = "@drawable/icon")]
      public class MainActivity : Activity,ILocationListener
          {
          private Location _currentLocation;
          private LocationManager _locationManager;
          private TextView _locationText;
          private TextView _addressText;
          private string _locationProvider;
  
  
          protected override void OnCreate(Bundle bundle)
          {
              base.OnCreate(bundle);
              SetContentView(Resource.Layout.Main);
  
              _addressText = FindViewById&lt;TextView&gt;(Resource.Id.address_text);
              _locationText = FindViewById&lt;TextView&gt;(Resource.Id.location_text);
  
              FindViewById&lt;TextView&gt;(Resource.Id.get_address_button).Click += AddressButton_OnClick;
              InitializeLocationManager();
  
  
          }
  
          public void InitializeLocationManager()
          {
              _locationManager = (LocationManager)GetSystemService(LocationService);
  
              Criteria criteriaForLocationService = new Criteria
              {
                  Accuracy = Accuracy.Fine
              };
              IList&lt;string&gt; acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
  
              if (acceptableLocationProviders.Any())
              {
                  _locationProvider = acceptableLocationProviders.First();
              }
              else
              {
                  _locationProvider = String.Empty;
              }
          }
  
  
          protected override void OnResume()
          {
              base.OnResume();
              _locationManager.RequestLocationUpdates(_locationProvider, 0, 0, this);
          }
  
  
          protected override void OnPause()
          {
              base.OnPause();
              _locationManager.RemoveUpdates(this);
          }
  
          async void AddressButton_OnClick(object sender, EventArgs eventArgs)
          {
              if (_currentLocation == null)
              {
                  _addressText.Text = "Can't determine the current location.";
                  return;
              }
  
              Geocoder geocoder = new Geocoder(this);
              IList&lt;Address&gt; addressList = await geocoder.GetFromLocationAsync(_currentLocation.Latitude, _currentLocation.Longitude, 10);
  
              Address address = addressList.FirstOrDefault();
              if (address != null)
              {
                  StringBuilder deviceAddress = new StringBuilder();
                  for (int i = 0; i &lt; address.MaxAddressLineIndex; i++)
                  {
                      deviceAddress.Append(address.GetAddressLine(i))
                          .AppendLine(",");
                  }
                  _addressText.Text = deviceAddress.ToString();
              }
              else
              {
                  _addressText.Text = "Unable to determine the address.";
              }
  
       }  
  
          public void OnLocationChanged(Location location)
          {
              _currentLocation = location;
              if (_currentLocation == null)
              {
                  _locationText.Text = "Unable to determine your location.";
              }
              else
              {
                  _locationText.Text = String.Format("{0},{1}", _currentLocation.Latitude, _currentLocation.Longitude);
              }
  
          }
  
          public void OnProviderDisabled(string provider) { }
  
          public void OnProviderEnabled(string provider) { }
  
          public void OnStatusChanged(string provider, Availability status, Bundle extras) { }
      }
  }
  </code></pre>