Search in sources :

Example 71 with LocationManager

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;
}
Also used : LocationManager(android.location.LocationManager)

Example 72 with LocationManager

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);
}
Also used : LocationManager(android.location.LocationManager)

Example 73 with LocationManager

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;
}
Also used : LocationManager(android.location.LocationManager)

Example 74 with LocationManager

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");
}
Also used : LocationManager(android.location.LocationManager) IOException(java.io.IOException)

Example 75 with LocationManager

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;
}
Also used : LocationManager(android.location.LocationManager) GsmCellLocation(android.telephony.gsm.GsmCellLocation) CellLocation(android.telephony.CellLocation) Location(android.location.Location) CdmaCellLocation(android.telephony.cdma.CdmaCellLocation)

Aggregations

LocationManager (android.location.LocationManager)151 Location (android.location.Location)51 Bundle (android.os.Bundle)33 LocationListener (android.location.LocationListener)29 Criteria (android.location.Criteria)21 Intent (android.content.Intent)20 BluetoothAdapter (android.bluetooth.BluetoothAdapter)15 View (android.view.View)10 SuppressLint (android.annotation.SuppressLint)9 IOException (java.io.IOException)9 ConnectivityManager (android.net.ConnectivityManager)7 WifiManager (android.net.wifi.WifiManager)7 TextView (android.widget.TextView)7 DialogInterface (android.content.DialogInterface)6 IntentFilter (android.content.IntentFilter)6 SharedPreferences (android.content.SharedPreferences)6 PendingIntent (android.app.PendingIntent)5 NetworkInfo (android.net.NetworkInfo)5 TelephonyManager (android.telephony.TelephonyManager)5 TrackerDataHelper (com.android.locationtracker.data.TrackerDataHelper)5