本文整理汇总了C#中Android.Locations.LocationManager.GetProviders方法的典型用法代码示例。如果您正苦于以下问题:C# LocationManager.GetProviders方法的具体用法?C# LocationManager.GetProviders怎么用?C# LocationManager.GetProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Locations.LocationManager
的用法示例。
在下文中一共展示了LocationManager.GetProviders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: start
public void start()
{
if (_tracking) return;
var ls = (LocationManager) _context.GetSystemService(Context.LocationService);
//var aproviders = ls.AllProviders.ToArray();
//var hasGPS = ls.IsProviderEnabled(LocationManager.GpsProvider);
//var hasNET = ls.IsProviderEnabled(LocationManager.NetworkProvider);
//if (!hasGPS || !hasNET)
{
//throw new Exception("Must have both GPS and Net location providers");
}
_locationManager = ls;
var lastLocation = _locationManager.GetLastKnownLocation(LocationManager.PassiveProvider);
Location = createGeoLocation(lastLocation);
var criteria = new Criteria();
criteria.Accuracy = Accuracy.Fine;
criteria.AltitudeRequired = true;
var providers = _locationManager.GetProviders(criteria, true).ToArray();
foreach (var provider in providers)
{
_locationManager.RequestLocationUpdates(provider, 1000, 5, _listener, Looper.MainLooper);
}
_tracking = true;
}
示例2: LocationTracker
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="context"></param>
public LocationTracker(Context context, string provider = LocationManager.GpsProvider)
{
locationMan = (LocationManager)context.GetSystemService(Service.LocationService);
if(locationMan.GetProviders(true).Contains(provider))
{
Provider = provider;
}
else if (locationMan.IsProviderEnabled(LocationManager.GpsProvider))
{
Provider = LocationManager.GpsProvider;
}
else if (locationMan.IsProviderEnabled(LocationManager.NetworkProvider))
{
Provider = LocationManager.NetworkProvider;
}
else
{
Criteria crit = new Criteria();
crit.Accuracy = Accuracy.Fine;
Provider = locationMan.GetBestProvider(crit, true);
}
LastGPSReceived = DateTime.MinValue;
}
示例3: InitializeLocationManager
private void InitializeLocationManager()
{
_locationManager = (LocationManager)GetSystemService(LocationService);
var kriteria = new Criteria { Accuracy = Accuracy.Fine };
var accepatbleLocationProvs = _locationManager.GetProviders(kriteria, true);
_locationProvider = accepatbleLocationProvs.Any() ? accepatbleLocationProvs.First() : string.Empty;
Log.Debug(TAG, "using : " + _locationProvider + ".");
}
示例4: Geolocator
public Geolocator( Context context )
{
if(context == null)
{
throw new ArgumentNullException( "context" );
}
manager = (LocationManager)context.GetSystemService( Context.LocationService );
providers =
manager.GetProviders( enabledOnly: false ).Where( s => s != LocationManager.PassiveProvider ).ToArray();
}
示例5: LocationTestService
public LocationTestService(Context context)
{
locationManager = (LocationManager)context.GetSystemService(Context.LocationService);
var criteriaForLocationService = new Criteria { Accuracy = Accuracy.Fine };
var acceptableLocationProviders = locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
locationProvider = acceptableLocationProviders.First();
}
}
示例6: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
ConnectivityManager connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService);
NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo;
Button loginButton = FindViewById<Button>(Resource.Id.loginButton);
Button filteButton = FindViewById<Button> (Resource.Id.button1);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
_locationManager = GetSystemService (Context.LocationService) as LocationManager;
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
filteButton.Click += (object sender, EventArgs e) => {
Intent intent = new Intent (this, typeof(FilterActivity));
StartActivityForResult (intent, 0);
};
loginButton.Click += (object sender, EventArgs e) => {
bool isOnline = (activeConnection != null) && activeConnection.IsConnected;
bool wifiIsOnline = (connectivityManager.GetNetworkInfo(ConnectivityType.Wifi)).IsConnected;
if (isOnline || wifiIsOnline) {
if (!string.IsNullOrEmpty (prefs.GetString ("token", ""))) {
Intent intent = new Intent (this, typeof(SearchActivity));
StartActivityForResult (intent, 0);
} else {
auth = Global.LogIn ();
auth.Completed += auth_Completed;
StartActivity (auth.GetUI (this));
}
}
else
{
AlertDialog.Builder alert = new AlertDialog.Builder (this);
alert.SetTitle ("Internet connection error");
alert.SetMessage ("Turn wifi or mobile data on");
alert.SetPositiveButton ("Ok", (senderAlert, args) => {
});
Dialog dialog = alert.Create();
dialog.Show();
}
};
}
示例7: OnCreate
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Create your fragment here
string lp = string.Empty;
_lm = (LocationManager) GetSystemService(LocationService);
Criteria cr = new Criteria { Accuracy = Accuracy.Fine };
IList<string> alp = _lm.GetProviders (cr, true);
if (alp.Any ()) {
lp = alp.First ();
_lm.RequestLocationUpdates (lp, this);
}
}
示例8: StartLocationManager
public void StartLocationManager(Action<MyLocation> callBack)
{
manager = (LocationManager) Android.App.Application.Context.GetSystemService (Context.LocationService);
_callBack = callBack;
Criteria criteriaForLocationService = new Criteria { Accuracy = Accuracy.Coarse };
IList<string> acceptableLocationProviders = manager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
manager.RequestLocationUpdates (acceptableLocationProviders.First (), 0, 0, this);
else
throw new LocationServiceNotRunningException ();
}
示例9: InitializeLocationManager
void InitializeLocationManager()
{
_locationManager = (LocationManager)GetSystemService(LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Count != 0)
{
_locationProvider = acceptableLocationProviders[0];
}
else
{
_locationProvider = string.Empty;
}
}
示例10: InitializeLocationManager
void InitializeLocationManager()
{
_locationManager = (LocationManager)GetSystemService(LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
_locationProvider = acceptableLocationProviders.First();
}
else
{
_locationProvider = String.Empty;
}
Log.Debug(LogTag, "Using " + _locationProvider + ".");
}
示例11: InitializeLocationManager
void InitializeLocationManager()
{
_locationManager = (LocationManager) Application.Context.GetSystemService(Application.LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
_locationProvider = acceptableLocationProviders.First();
}
else
{
_locationProvider = string.Empty;
}
}
示例12: LocListener
public LocListener(LocationManager lm, SensorManager sm) : base()
{
// Get LocationManager
locManager = lm;
var locationCriteria = new Criteria ()
{
Accuracy = global::Android.Locations.Accuracy.Fine,
AltitudeRequired = true,
PowerRequirement = Power.Low
};
locationProvider = locManager.GetBestProvider(locationCriteria, true);
if (locationProvider == null)
throw new Exception("No location provider found");
List<String> providers = locManager.GetProviders(true) as List<String>;
// Loop over the array backwards, and if you get an accurate location, then break out the loop
Location loc = null;
if (providers != null) {
for (int i = providers.Count - 1; i >= 0; i--) {
loc = locManager.GetLastKnownLocation(providers[i]);
if (loc != null)
break;
}
}
if (loc != null)
{
lat = loc.Latitude;
lon = loc.Longitude;
alt = loc.Altitude;
accuracy = loc.Accuracy;
}
sensorManager = sm;
accelerometer = sensorManager.GetDefaultSensor(SensorType.Accelerometer);
magnetometer = sensorManager.GetDefaultSensor(SensorType.MagneticField);
}
示例13: InitializeLocationManager
private void InitializeLocationManager()
{
m_LocationManager = (LocationManager)GetSystemService(LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = m_LocationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
m_LocationProvider = acceptableLocationProviders.First();
}
else
{
m_LocationProvider = String.Empty;
}
m_LocationManager.RequestLocationUpdates(LocationManager.GpsProvider, 5000, 10, this);
}
示例14: InitLocationService
public void InitLocationService()
{
var wrapper = new Android.Content.ContextWrapper(Forms.Context);
_locationManager = (LocationManager) wrapper.GetSystemService(Context.LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
_locationProvider = acceptableLocationProviders.First();
_locationManager.RequestLocationUpdates(_locationProvider, 2000, 10, this);
}
else
{
_locationProvider = String.Empty;
}
Console.WriteLine("Using " + _locationProvider + ".");
}
示例15: InitializeLocationManager
void InitializeLocationManager()
{
_locationManager = (LocationManager)GetSystemService(LocationService);
Criteria criteriaForLocationService = new Criteria
{
Accuracy = Accuracy.Fine
};
IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
if (acceptableLocationProviders.Any())
{
_locationProvider = acceptableLocationProviders.First();
}
else
{
_locationProvider = String.Empty;
}
FindViewById<TextView> (Resource.Id.btnCheckIn).Enabled = true;
}