Example usage for android.location GpsStatus GPS_EVENT_STARTED

List of usage examples for android.location GpsStatus GPS_EVENT_STARTED

Introduction

In this page you can find the example usage for android.location GpsStatus GPS_EVENT_STARTED.

Prototype

int GPS_EVENT_STARTED

To view the source code for android.location GpsStatus GPS_EVENT_STARTED.

Click Source Link

Document

Event sent when the GPS system has started.

Usage

From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java

private void startStreamingInternalSensorData() {
    internalSensorManager = new InternalSensorManager(root, new int[] { 1000, 1000, 1000 }, this);
    internalSensorManager.startStreaming();

    locationListener = new GPSListener(getString(R.string.file_name_gps_position), this.directoryName, 25,
            this);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ContextCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] {
                android.Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION },
                PERMISSIONS_REQUEST);/*  w  w w  . java 2 s. c  om*/

    } else {
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
        locationManager.addGpsStatusListener(new GpsStatus.Listener() {
            @Override
            public void onGpsStatusChanged(int event) {
                switch (event) {
                case GpsStatus.GPS_EVENT_STARTED:
                    gpsStatusText = getString(R.string.info_connected);
                    break;
                case GpsStatus.GPS_EVENT_STOPPED:
                    gpsStatusText = getString(R.string.info_not_connected);
                    break;
                case GpsStatus.GPS_EVENT_FIRST_FIX:
                    gpsStatusText = getString(R.string.info_connected_fix_received);
                    break;
                }
            }
        });
    }
}