Search in sources :

Example 11 with LocationManager

use of android.location.LocationManager in project weiciyuan by qii.

the class WriteWeiboActivity method addLocation.

private void addLocation() {
    LocationManager locationManager = (LocationManager) WriteWeiboActivity.this.getSystemService(Context.LOCATION_SERVICE);
    if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) && !locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        Toast.makeText(WriteWeiboActivity.this, getString(R.string.please_open_gps), Toast.LENGTH_SHORT).show();
        return;
    }
    Toast.makeText(WriteWeiboActivity.this, getString(R.string.gps_is_searching), Toast.LENGTH_SHORT).show();
    if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, locationListener);
    }
    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, locationListener);
    }
}
Also used : LocationManager(android.location.LocationManager)

Example 12 with LocationManager

use of android.location.LocationManager in project weiciyuan by qii.

the class WriteWeiboActivity method updateWithNewLocation.

private void updateWithNewLocation(Location result) {
    haveGPS.setVisibility(View.VISIBLE);
    geoBean = new GeoBean();
    geoBean.setLatitude(result.getLatitude());
    geoBean.setLongitude(result.getLongitude());
    if (Utility.isTaskStopped(locationTask)) {
        locationTask = new GetGoogleLocationInfo(geoBean);
        locationTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    }
    ((LocationManager) WriteWeiboActivity.this.getSystemService(Context.LOCATION_SERVICE)).removeUpdates(locationListener);
}
Also used : LocationManager(android.location.LocationManager) GeoBean(org.qii.weiciyuan.bean.GeoBean)

Example 13 with LocationManager

use of android.location.LocationManager in project platform_frameworks_base by android.

the class ExternalSharedPermsTest method testRunLocationAndBluetooth.

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

Example 14 with LocationManager

use of android.location.LocationManager in project simplefacebook by androidquery.

the class PlaceActivity method refreshButton.

private void refreshButton() {
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    boolean enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    if (enabled) {
        aq.id(R.id.button_gps).gone();
    } else {
        aq.id(R.id.button_gps).visible();
    }
    refreshHint();
}
Also used : LocationManager(android.location.LocationManager)

Example 15 with LocationManager

use of android.location.LocationManager in project platform_frameworks_base by android.

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)

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