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 android_frameworks_base by ParanoidAndroid.
the class TrackerService method stopListeners.
/**
* De-registers all location listeners, closes persistent storage
*/
protected synchronized void stopListeners() {
LocationManager lm = getLocationManager();
if (mListeners != null) {
for (LocationTrackingListener listener : mListeners) {
lm.removeUpdates(listener);
}
mListeners.clear();
}
mListeners = null;
// stop cell state listener
if (mTelephonyManager != null) {
mTelephonyManager.listen(mPhoneStateListener, 0);
}
// stop network/wifi listener
if (mNetwork != null) {
unregisterReceiver(mNetwork);
}
mNetwork = null;
mTrackerData = null;
if (mPrefListener != null) {
getPreferences().unregisterOnSharedPreferenceChangeListener(mPrefListener);
mPrefListener = null;
}
}
use of android.location.LocationManager in project android_frameworks_base by ParanoidAndroid.
the class ExternalSharedPermsDiffKeyTest method testRunBluetoothAndFineLocation.
/** The use of location manager and bluetooth below are simply to simulate an app that
* tries to use them, so we can verify whether permissions are granted and accessible.
* */
public void testRunBluetoothAndFineLocation() {
LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onLocationChanged(Location location) {
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
});
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if ((mBluetoothAdapter != null) && (!mBluetoothAdapter.isEnabled())) {
mBluetoothAdapter.getName();
}
fail("this app was signed by a different cert and should crash/fail to run by now");
}
use of android.location.LocationManager in project android_frameworks_base by ParanoidAndroid.
the class ExternalSharedPermsFLTest method testRunFineLocation.
/** The use of location manager below is simply to simulate an app that
* tries to use it, so we can verify whether permissions are granted and accessible.
* */
public void testRunFineLocation() {
LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onLocationChanged(Location location) {
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
});
}
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