Search in sources :

Example 1 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 2 with LocationManager

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

Example 3 with LocationManager

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");
}
Also used : LocationManager(android.location.LocationManager) Bundle(android.os.Bundle) LocationListener(android.location.LocationListener) BluetoothAdapter(android.bluetooth.BluetoothAdapter) Location(android.location.Location)

Example 4 with LocationManager

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) {
        }
    });
}
Also used : LocationManager(android.location.LocationManager) Bundle(android.os.Bundle) LocationListener(android.location.LocationListener) Location(android.location.Location)

Example 5 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)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