Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle location service updates ignoring location listener (android)
    primarykey
    data
    text
    <p>I have an app which registers a locationClient for updates. However, the location listener never seems to get accessed. The "GPS connected" toast appears, so I know the GPS connects ok, but the toast displaying the coordinates does not display, and the listener being activated is not logged. However, "location updates activated" is logged. "connector" is an object which initiates an Asynctask to get database data. It works fine. </p> <pre><code>@Override public void onConnected(Bundle arg0) { Toast.makeText(context, "GPS connected", Toast.LENGTH_SHORT).show(); connector = new Connector(); connector.execute("clues", null, null); listener = new LocationListener() { @Override public void onLocationChanged(Location location) { Log.d("location", "listener activated"); try { double[] coords = locationCoords(location); if(coords[0] != 0) { map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(coords[0], coords[1]), (float) 14.5)); } Toast.makeText(context, coords[0] + ", " + coords[1], Toast.LENGTH_LONG).show(); } catch(NullPointerException e) { Log.d("nulls", "null"); } } }; mLocationClient.requestLocationUpdates(mLocationRequest, listener); Log.d("location", "location updates initiated"); } </code></pre> <p>This is the log of the relevant bits. "map null" is logging a different issue, which is that my google maps fragment is not yet initialized when I try to instantiate it. </p> <pre><code>07-12 15:15:36.608: D/dalvikvm(1116): GC_FOR_ALLOC freed 133K, 9% free 3105K/3392K, paused 46ms, total 49ms 07-12 15:15:36.618: I/dalvikvm-heap(1116): Grow heap (frag case) to 3.757MB for 635812-byte allocation 07-12 15:15:36.688: D/dalvikvm(1116): GC_FOR_ALLOC freed &lt;1K, 8% free 3726K/4016K, paused 65ms, total 65ms 07-12 15:15:36.818: D/dalvikvm(1116): GC_CONCURRENT freed 2K, 7% free 3742K/4016K, paused 8ms+6ms, total 130ms 07-12 15:15:37.208: D/null(1116): map null 07-12 15:15:37.228: D/location(1116): location request constructed 07-12 15:15:37.368: D/null(1116): map null 07-12 15:15:38.198: D/dalvikvm(1116): GC_CONCURRENT freed 141K, 7% free 3994K/4260K, paused 6ms+59ms, total 252ms 07-12 15:15:38.478: D/libEGL(1116): loaded /system/lib/egl/libEGL_emulation.so 07-12 15:15:38.519: D/(1116): HostConnection::get() New Host Connection established 0x2a19b220, tid 1116 07-12 15:15:38.559: D/libEGL(1116): loaded /system/lib/egl/libGLESv1_CM_emulation.so 07-12 15:15:38.608: D/libEGL(1116): loaded /system/lib/egl/libGLESv2_emulation.so 07-12 15:15:39.008: W/EGL_emulation(1116): eglSurfaceAttrib not implemented 07-12 15:15:39.068: D/OpenGLRenderer(1116): Enabling debug mode 0 07-12 15:15:39.258: D/(1116): HostConnection::get() New Host Connection established 0x2a1b0310, tid 1140 07-12 15:15:39.268: I/Choreographer(1116): Skipped 93 frames! The application may be doing too much work on its main thread. 07-12 15:15:40.028: D/dalvikvm(1116): GC_FOR_ALLOC freed 345K, 12% free 4030K/4564K, paused 95ms, total 106ms 07-12 15:15:40.398: D/dalvikvm(1116): GC_CONCURRENT freed 328K, 11% free 4179K/4696K, paused 10ms+13ms, total 130ms 07-12 15:15:41.248: D/location(1116): location updates initiated 07-12 15:15:41.268: D/dalvikvm(1116): GC_CONCURRENT freed 611K, 17% free 4084K/4864K, paused 7ms+61ms, total 340ms </code></pre> <p>This log is from an emulator, but the same behavior happens on a real device. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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