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