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 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);
}
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;
}
}
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());
}
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));
}
Aggregations