use of android.location.LocationManager in project QLibrary by DragonsQC.
the class NetStateUtils method isGpsEnabled.
/**
* 判断GPS是否打开
*
* @return GPS是否打开
*/
public static boolean isGpsEnabled() {
LocationManager lm = ((LocationManager) QLibrary.getInstance().getContext().getSystemService(Context.LOCATION_SERVICE));
if (lm == null) {
return false;
}
List<String> providers = lm.getProviders(true);
return providers != null && providers.size() > 0;
}
use of android.location.LocationManager in project AndEngine by nicolasgramlich.
the class Engine method disableLocationSensor.
public void disableLocationSensor(final Context pContext) {
final LocationManager locationManager = (LocationManager) pContext.getSystemService(Context.LOCATION_SERVICE);
locationManager.removeUpdates(this);
}
use of android.location.LocationManager in project wire-android by wireapp.
the class LocationFragment method isLocationServicesEnabled.
private boolean isLocationServicesEnabled() {
if (!hasLocationPermission()) {
return false;
}
// We are creating a local locationManager here, as it's not sure we already have one
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (locationManager == null) {
return false;
}
boolean gpsEnabled;
boolean netEnabled;
try {
gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (Exception e) {
gpsEnabled = false;
}
try {
netEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch (Exception e) {
netEnabled = false;
}
return netEnabled || gpsEnabled;
}
use of android.location.LocationManager in project GT by Tencent.
the class GTGPSReplayEngine method stopMockLocation.
/**
* add on 20140630
* 退出应用前也需要调用停止模拟位置,否则手机的正常GPS定位不会恢复
*/
public void stopMockLocation() {
try {
mMockGpsProviderTask.cancel(true);
mMockGpsProviderTask = null;
} catch (Exception e) {
}
try {
LocationManager locationManager = (LocationManager) GTApp.getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.removeTestProvider(MockGpsProvider.GPS_MOCK_PROVIDER);
} catch (Exception e) {
}
sendMockBroadcast(GTApp.getContext(), "stop");
}
use of android.location.LocationManager in project carat by amplab.
the class SamplingLibrary method getLastKnownLocation.
private static Location getLastKnownLocation(Context context, String provider) {
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Location l = lm.getLastKnownLocation(provider);
return l;
}
Aggregations