Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Handler.getLooper() returns null
    primarykey
    data
    text
    <p>I have following problem. I have this implementation of my Thread with Looper.</p> <pre><code>public class GeoLocationThread extends Thread{ public Handler handler; private General general; public void run(){ Looper.prepare(); handler = new IncomingHandler(general); Looper.loop(); } public GeoLocationThread(General general){ this.general=general; } private static class IncomingHandler extends Handler{ private final WeakReference&lt;General&gt; mService; IncomingHandler(General service) { mService = new WeakReference&lt;General&gt;(service); } @Override public void handleMessage(Message msg) { General service = mService.get(); if (service != null) { Location location=service.getLl().getLocation(); if(location.getAccuracy()&lt;40){ service.setOrigin(new GeoPoint((int) (location.getLatitude() * 1E6),(int) (location.getLongitude() * 1E6))); } } } } </code></pre> <p>}</p> <p>and i would like to do the following:</p> <pre><code>GeoLocationThread locationThread=new GeoLocationThread(this); locationThread.start(); lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, ll, locationThread.handler.getLooper()); </code></pre> <p>Where lm is LocationManager. From my log and testing I am able to say that <code>locationThread.handler.getLooper()</code> returns null instead of the Looper. </p> <p>I don't know why it is null. I have tried to call <code>locationThread.isAlive()</code> which has returned true. I have also tried to get <code>locationThread.handler;</code> which I know is not null. I have also done the lot of googling, but I haven't found more than the documentaion.</p> <p>Thank you very much in advance for your answers.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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