Search in sources :

Example 6 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 7 with LocationManager

use of android.location.LocationManager in project actor-platform by actorapp.

the class MapPickerActivity method setUpMap.

/**
     * This is where we can add markers or lines, add listeners or move the camera. In this case, we
     * just add a marker near Africa.
     * <p/>
     * This should only be called once and when we are sure that {@link #mMap} is not null.
     */
private void setUpMap() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, PERMISSION_REQ_LOCATION);
            im.actor.runtime.Log.d("Permissions", "MapPickerActivity.setUpMap - no permission :c");
            return;
        }
    }
    LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    for (String provider : locationManager.getAllProviders()) {
        currentLocation = locationManager.getLastKnownLocation(provider);
        if (currentLocation != null) {
            break;
        }
    }
    if (currentLocation != null) {
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()), 14));
        fetchPlaces(null);
    }
    mMap.setOnMyLocationChangeListener(this);
    mMap.getUiSettings().setMyLocationButtonEnabled(false);
    mMap.getUiSettings().setZoomControlsEnabled(false);
    mMap.getUiSettings().setCompassEnabled(false);
    mMap.setMyLocationEnabled(true);
    mMap.setOnMapLongClickListener(this);
    mMap.setOnMarkerClickListener(this);
}
Also used : LocationManager(android.location.LocationManager) LatLng(com.google.android.gms.maps.model.LatLng)

Example 8 with LocationManager

use of android.location.LocationManager in project Klyph by jonathangerbaud.

the class PlacePickerActivity method onStop.

@Override
protected void onStop() {
    super.onStop();
    if (locationListener != null) {
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.removeUpdates(locationListener);
        locationListener = null;
    }
}
Also used : LocationManager(android.location.LocationManager)

Example 9 with LocationManager

use of android.location.LocationManager in project AndroidTraining by mixi-inc.

the class DefaultModule method configure.

@SuppressWarnings("unchecked")
protected void configure() {
    bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
    bind(Context.class).toProvider(ContextProvider.class);
    bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
    bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
    bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
    bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
    bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
    bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
    bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
    bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
    bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
    bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
    bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
    bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
    bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
    bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
    bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
    bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
    bind(ObserverManager.class);
    bindProviderListener(new ObserverRegister());
    bind(StateManager.class).in(ApplicationScoped.class);
    bind(StateEventObserver.class);
    bindFieldListener(RetainState.class, new RetainStateListener());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Example 10 with LocationManager

use of android.location.LocationManager in project AndEngine by nicolasgramlich.

the class Engine method enableLocationSensor.

public void enableLocationSensor(final Context pContext, final ILocationListener pLocationListener, final LocationSensorOptions pLocationSensorOptions) {
    this.mLocationListener = pLocationListener;
    final LocationManager locationManager = (LocationManager) pContext.getSystemService(Context.LOCATION_SERVICE);
    final String locationProvider = locationManager.getBestProvider(pLocationSensorOptions, pLocationSensorOptions.isEnabledOnly());
    // TODO locationProvider can be null, in that case return false. Successful case should return true.
    locationManager.requestLocationUpdates(locationProvider, pLocationSensorOptions.getMinimumTriggerTime(), pLocationSensorOptions.getMinimumTriggerDistance(), this);
    this.onLocationChanged(locationManager.getLastKnownLocation(locationProvider));
}
Also used : LocationManager(android.location.LocationManager)

Aggregations

LocationManager (android.location.LocationManager)70 Location (android.location.Location)31 Bundle (android.os.Bundle)23 LocationListener (android.location.LocationListener)22 BluetoothAdapter (android.bluetooth.BluetoothAdapter)12 Criteria (android.location.Criteria)8 IntentFilter (android.content.IntentFilter)5 TrackerDataHelper (com.android.locationtracker.data.TrackerDataHelper)5 IOException (java.io.IOException)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2 SensorManager (android.hardware.SensorManager)2 FacebookException (com.facebook.FacebookException)2 ArrayList (java.util.ArrayList)2 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)2 ActivityManager (android.app.ActivityManager)1 AlarmManager (android.app.AlarmManager)1 KeyguardManager (android.app.KeyguardManager)1 NotificationManager (android.app.NotificationManager)1 Context (android.content.Context)1