Example usage for android.location LocationProvider OUT_OF_SERVICE

List of usage examples for android.location LocationProvider OUT_OF_SERVICE

Introduction

In this page you can find the example usage for android.location LocationProvider OUT_OF_SERVICE.

Prototype

int OUT_OF_SERVICE

To view the source code for android.location LocationProvider OUT_OF_SERVICE.

Click Source Link

Usage

From source file:org.runnerup.tracker.GpsStatus.java

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    if (provider.equalsIgnoreCase("gps")) {
        if (status == LocationProvider.OUT_OF_SERVICE || status == LocationProvider.TEMPORARILY_UNAVAILABLE) {
            clear(true);//w w w . ja  v  a 2 s  .  c  om
        }
        if (listener != null)
            listener.onTick();
    }
}

From source file:com.nextgis.firereporter.SendReportActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.report);/*from   w  ww .  ja  v a 2  s .c om*/

    //add fragment
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    frCompass = (CompassFragment) getSupportFragmentManager().findFragmentByTag("COMPASS");
    if (frCompass == null) {
        frCompass = new CompassFragment();
        fragmentTransaction.add(R.id.compass_fragment_container, frCompass, "COMPASS").commit();
    }

    getSupportFragmentManager().executePendingTransactions();

    getSupportActionBar().setHomeButtonEnabled(true);

    edLatitude = (EditText) findViewById(R.id.edLatitude);
    edLongitude = (EditText) findViewById(R.id.edLongitude);
    edAzimuth = (EditText) findViewById(R.id.edAzimuth);
    edDistance = (EditText) findViewById(R.id.edDistance);
    edComment = (EditText) findViewById(R.id.edComment);

    edDistance.setText("100");

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    if (mLocationManager != null) {

        for (String aProvider : mLocationManager.getProviders(false)) {
            if (aProvider.equals(LocationManager.GPS_PROVIDER)) {
                gpsAvailable = true;
            }
        }

        if (gpsAvailable) {
            Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

            if (location != null) {
                float lat = (float) (location.getLatitude());
                float lon = (float) (location.getLongitude());
                edLatitude.setText(Float.toString(lat));
                edLongitude.setText(Float.toString(lon));
            } else {
                edLatitude.setText(getString(R.string.noLocation));
                edLongitude.setText(getString(R.string.noLocation));
            }

            mLocationListener = new LocationListener() {
                public void onStatusChanged(String provider, int status, Bundle extras) {
                    switch (status) {
                    case LocationProvider.OUT_OF_SERVICE:
                        break;
                    case LocationProvider.TEMPORARILY_UNAVAILABLE:
                        break;
                    case LocationProvider.AVAILABLE:
                        break;
                    }
                }

                public void onProviderEnabled(String provider) {
                }

                public void onProviderDisabled(String provider) {
                }

                public void onLocationChanged(Location location) {
                    float lat = (float) (location.getLatitude());
                    float lon = (float) (location.getLongitude());
                    edLatitude.setText(Float.toString(lat));
                    edLongitude.setText(Float.toString(lon));

                    // FIXME: also need to calculate declination?
                }
            }; // location listener
        } else {
            edLatitude.setText(getString(R.string.noGPS));
            edLongitude.setText(getString(R.string.noGPS));
            edLatitude.setEnabled(false);
            edLongitude.setEnabled(false);
        }
    }

    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    boolean accelerometerAvailable = false;
    boolean magnetometerAvailable = false;
    for (Sensor aSensor : mSensorManager.getSensorList(Sensor.TYPE_ALL)) {
        if (aSensor.getType() == Sensor.TYPE_ACCELEROMETER) {
            accelerometerAvailable = true;
        } else if (aSensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
            magnetometerAvailable = true;
        }
    }

    compassAvailable = accelerometerAvailable && magnetometerAvailable;
    if (compassAvailable) {
        //frCompass = (CompassFragment) getSupportFragmentManager().findFragmentByTag("COMPASS");
        if (frCompass != null) {
            frCompass.SetAzimuthCtrl(edAzimuth);
        }
    } else {
        edAzimuth.setText(getString(R.string.noCompass));
        edAzimuth.setEnabled(false);
    }
}

From source file:prgc.snct.sos.Activities.MapActivity2.java

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    switch (status) {
    case LocationProvider.AVAILABLE:
        Log.v("Status", "AVAILABLE");
        break;// ww  w.  ja  v  a 2 s. c o m
    case LocationProvider.OUT_OF_SERVICE:
        Log.v("Status", "OUT_OF_SERVICE");
        break;
    case LocationProvider.TEMPORARILY_UNAVAILABLE:
        Log.v("Status", "TEMPORARILY_UNAVAILABLE");
        break;
    }
}

From source file:tcc.iesgo.activity.ClientMapActivity.java

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    switch (status) {
    case LocationProvider.OUT_OF_SERVICE:
        //Log.v(tag, "Status alterado: Fora de servio");
        break;//w w w .  j ava2 s  .c o m
    case LocationProvider.TEMPORARILY_UNAVAILABLE:
        //Log.v(tag, "Status alterado: Temporariamente indisponvel");
        break;
    case LocationProvider.AVAILABLE:
        //Log.v(tag, "Status alterado: Disponvel");
        break;
    }
}

From source file:io.kristal.locationplugin.LocationPlugin.java

@Override
public void onStatusChanged(String provider, int status, Bundle bundle) {
    switch (status) {
    case LocationProvider.AVAILABLE:
        onProviderEnabled(provider);/*from w  w w . ja va  2  s  . c  om*/
        break;
    case LocationProvider.OUT_OF_SERVICE:
        onProviderDisabled(provider);
        break;
    // TODO: what to do in this case?
    //case LocationProvider.TEMPORARILY_UNAVAILABLE:
    }
}

From source file:gov.nasa.arc.geocam.geocam.GeoCamMobile.java

private void updateLocation(Location location) {
    double lat, lon;
    int status;//from   w ww. j  av  a 2 s  .c  o m

    if (location == null) {
        lat = 0.0;
        lon = 0.0;
        status = LocationProvider.TEMPORARILY_UNAVAILABLE;
    } else {
        mLocation = location;
        mLocationProvider = mLocation.getProvider();
        status = LocationProvider.AVAILABLE;
        lat = mLocation.getLatitude();
        lon = mLocation.getLongitude();
    }

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(6);
    TextView latText = (TextView) findViewById(R.id.main_latitude_textview);
    TextView lonText = (TextView) findViewById(R.id.main_longitude_textview);
    latText.setText(nf.format(lat) + DEGREE_SYMBOL);
    lonText.setText(nf.format(lon) + DEGREE_SYMBOL);

    ((TextView) findViewById(R.id.main_location_provider_textview)).setText(mLocationProvider);
    TextView locationStatusText = ((TextView) findViewById(R.id.main_location_status_textview));
    switch (status) {
    case LocationProvider.AVAILABLE:
        locationStatusText.setText("available");
        break;
    case LocationProvider.TEMPORARILY_UNAVAILABLE:
        locationStatusText.setText("unavailable");
        break;
    case LocationProvider.OUT_OF_SERVICE:
        locationStatusText.setText("no service");
        break;
    default:
        locationStatusText.setText("unknown");
        break;
    }
}

From source file:org.path.episample.android.fragments.NavigateFragment.java

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    switch (status) {
    case LocationProvider.AVAILABLE:
        if (mDirectionProvider.getCurrentLocation() != null) {
            updateNotification();//from ww w .j a v  a 2  s. c  o m
        }
        break;
    case LocationProvider.OUT_OF_SERVICE:
        break;
    case LocationProvider.TEMPORARILY_UNAVAILABLE:
        break;
    }
}

From source file:biz.bokhorst.bpt.BPTService.java

@Override
public void onStatusChanged(String s, int i, Bundle b) {
    if (locating)
        if (i == LocationProvider.OUT_OF_SERVICE)
            sendStatus(getString(R.string.StatusNoService));
        else if (i == LocationProvider.TEMPORARILY_UNAVAILABLE)
            sendStatus(getString(R.string.StatusUnavailable));
        else if (i == LocationProvider.AVAILABLE)
            sendStatus(getString(R.string.StatusAvailable));
        else//from  w w  w  . ja  v a 2  s . co  m
            sendStatus(String.format("Status %d", i));
}

From source file:com.trailbehind.android.iburn.map.MapActivity.java

/**
 * Sets the location source./*from w w w. j av  a 2 s .  c  o  m*/
 */
private void setupLocationSource() {
    final AppLocationProvider locProvider = getActiveLocationProvider();

    locProvider.setLocationMarker(createLocationMarker());
    locProvider.setLocationListener(new AppLocationListener() {

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            if (LocationManager.GPS_PROVIDER.equalsIgnoreCase(provider)) {
                if (status == LocationProvider.OUT_OF_SERVICE) {
                    mProgressBar.setVisibility(View.VISIBLE);
                    mMessageTextView.setText(R.string.msg_locating);

                    UIUtils.showPanel(getBaseContext(), mMessagePanel, false);
                } else {
                    UIUtils.hidePanel(getBaseContext(), mMessagePanel, false);
                }
            }
        }

        @Override
        public void onProviderEnabled(String provider) {
            if (LocationManager.GPS_PROVIDER.equalsIgnoreCase(provider)) {
                checkGPSProvider();
            }
        }

        @Override
        public void onProviderDisabled(String provider) {
            if (LocationManager.GPS_PROVIDER.equalsIgnoreCase(provider)) {
                checkGPSProvider();
            }
        }

        @Override
        public void onLocationChanged(String provider, Location location) {
            if (LocationManager.GPS_PROVIDER.equalsIgnoreCase(provider)) {
                if (Globals.sCurrentGPSLocation == null) {
                    CompassUtils.updateUserBearing(false, location.getBearing());
                } else {
                    final boolean hasBearing = location.hasBearing();
                    final float pointBearing = MapUtils.calculateBearing(Globals.sCurrentGPSLocation, location);
                    CompassUtils.updateUserBearing(hasBearing,
                            (hasBearing) ? location.getBearing() : pointBearing);
                }

                if (mMessagePanel.getVisibility() == View.VISIBLE) {
                    mProgressBar.setVisibility(View.GONE);
                    UIUtils.hidePanel(getBaseContext(), mMessagePanel, false);
                }
            } else {
                CompassUtils.updateUserBearing(false, location.getBearing());

                if (mGetMyLocation) {
                    final AppLocationProvider locProvider = getActiveLocationProvider();
                    final LocationMarker locationMarker = locProvider.getLocationMarker();
                    locationMarker.updatePosition();
                }
            }
        }

        @Override
        public void onProviderChanged(String oldProvider, String newProvider) {
            if (LocationManager.GPS_PROVIDER.equalsIgnoreCase(newProvider)) {
                mMapComponent.removeLocationSource();

                final AppLocationProvider locProvider = getActiveLocationProvider();
                final LocationMarker locationMarker = createLocationMarker();

                locProvider.setLocationMarker(locationMarker);
                mMapComponent.setLocationSource(locProvider);

                locationMarker.setTrackingEnabled(mGetMyLocation);
            }
        }
    });

    mMapComponent.setLocationSource(locProvider);
}

From source file:net.e_fas.oss.tabijiman.MapsActivity.java

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

    e_print("onStatusChanged");

    switch (status) {
    case LocationProvider.AVAILABLE:
        e_print("AVAILABLE");
        break;//ww  w .j  a v a  2 s.  c  o m
    case LocationProvider.OUT_OF_SERVICE:
        e_print("OUT_OF_SERVICE");
        break;
    case LocationProvider.TEMPORARILY_UNAVAILABLE:
        e_print("TEMPORARILY_UNAVAILABLE");
        break;

    }
}