Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid app crashing (looper = null)
    primarykey
    data
    text
    <p>I have a problem with my app. My application is actually a service. I have Main extends Service, it has private Looper looper variable to get HandlerThread looper. In <code>onCreate</code> function I initialize location manager, location listener and HandlerThread (which sets its looper to looper variable), then I try to use <code>requestLocationUpdates</code> passing the looper variable as looper. I gets an error</p> <pre><code>09-22 17:30:24.069: E/AndroidRuntime(1414): Caused by: java.lang.IllegalArgumentException: looper==null </code></pre> <p>Should I do anything else to this HandlerThread? Maybe start it?:></p> <p>I don't paste any code since it's quite long and I don't know the relevant part which would be appropriate to solve the problem. Therefore I'd love to pass any code You may need (HandlerThread? Anything else?)</p> <p>Thanks for any help.</p> <p><em><strong></em>**</strong> EDIT <strong><em>*</em>*</strong></p> <p>Alright, onCreate function:</p> <pre><code>public void onCreate() { super.onCreate(); Log.d("Service", "Service onCreate starts"); running = true; lt = new LooperThread("GPSIntentLT"); serviceLocationM = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); serviceLocationL = new MyLocationListener(); requestUpdates(serviceLocationL); Log.d("Service", "Service onCreate ends"); } </code></pre> <p>requestUpdates function (called above, there the error appears):</p> <pre><code>private void requestUpdates(LocationListener listener) { Log.d("Service", "requestUpdates starts"); serviceLocationM.removeUpdates(listener); flag = displayGpsStatus(); switch(flag) { case 0: Log.d("Service", "No Location Provider"); break; case 1: Log.d("Service", "Network Provider"); serviceLocationM.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10, 25, listener, theLooper); break; case 2: Log.d("Service", "GPS Provider"); serviceLocationM.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10, 25, listener, theLooper); break; } Log.d("Service", "requestUpdates ends"); } </code></pre> <p>And HandlerThread:</p> <pre><code>private class LooperThread extends HandlerThread{ public LooperThread(String name) { super(name); Log.d("Service", "LooperThread constructor starts"); theLooper = getLooper(); Log.d("Service", "LooperThread constructor ends"); } @Override public void run() { super.run(); Log.d("Service", "LooperThread run called"); } } </code></pre> <p>And at the end, logcat for this app:</p> <pre><code>09-22 18:21:47.997: D/Service(386): Service onCreate starts 09-22 18:21:47.997: D/Service(386): LooperThread constructor starts 09-22 18:21:48.007: D/Service(386): LooperThread constructor ends </code></pre> <p>So it does go down on requestLocationUpdates function, it happens on 2.2 emulator, on 2.3.3 it crashes the whole emulator by killing its processes (?).</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