Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>just tested this:</p> <pre><code>public class TestActivity extends Activity { private LocationManager mLocationManager; private PrisLocationListener mLocationListener; private PrisGpsListener mGpsListener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); PrisLocationListener locationListener = new PrisLocationListener(); HandlerThread t = new HandlerThread("LocationHandlerThread"); t.start(); mLocationManager = (LocationManager)getSystemService(LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener, t.getLooper()); mGpsListener = new PrisGpsListener(); mLocationManager.addGpsStatusListener(mGpsListener); } @Override protected void onPause() { super.onPause(); mLocationManager.removeUpdates(mLocationListener); mLocationManager.removeGpsStatusListener(mGpsListener); } public static class PrisLocationListener implements LocationListener{ private static final String TAG = PrisLocationListener.class.getSimpleName(); @Override public void onLocationChanged(Location arg0) { Log.d(TAG, "onLocationChanged: loc=" + arg0); } @Override public void onProviderDisabled(String provider) { Log.d(TAG, "onProviderDisabled: provider=" + provider); } @Override public void onProviderEnabled(String provider) { Log.d(TAG, "onProviderEnabled: provider=" + provider); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { Log.d(TAG, "onStatusChanged: provider=" + provider + ", status=" + status + ", extras=" + extras); } } public static class PrisGpsListener implements GpsStatus.Listener{ private static final String TAG = PrisGpsListener.class.getSimpleName(); @Override public void onGpsStatusChanged(int event) { Log.d(TAG, "onGpsStatusChanged: event=" + event); } } } </code></pre> <p>My Log output </p> <blockquote> <p>11-26 12:03:58.707: D/PrisGpsListener(24412): onGpsStatusChanged: event=1 11-26 12:04:00.199: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:01.199: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:02.199: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:03.207: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:04.207: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:05.199: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:06.199: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:07.191: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:08.207: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:09.215: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:10.207: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:11.207: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:12.207: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:13.215: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:14.223: D/PrisGpsListener(24412): onGpsStatusChanged: event=4 11-26 12:04:15.223: D/PrisGpsListener(24412): onGpsStatusChanged: event=4</p> </blockquote> <p>So <code>GpsStatus.Listener</code> is actually working. I guess you will recieve Location fixes if you move your phone. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload