Reputation: 179
Hi I'm trying to requestLocationUpdates from a Thread other than the UI Thread, I'm getting a RuntimeExeption in the following line:
// request location updates using Cellular
lm.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
0,
0,
locationListener);
Then reading the documentation it says that it Throws:
IllegalArgumentException if provider is null or doesn't exist on this device
IllegalArgumentException if listener is null
RuntimeException if the calling thread has no Looper
SecurityException if no suitable permission is present
So it seems to be that my thread has no Looper, but the problem is that I don't know what they mean by a "Looper". Thanks in advance!
Upvotes: 1
Views: 1154
Reputation: 1410
U can try this :
lm.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
0,
0,
locationListener,
Looper.myLooper()
);
Upvotes: 0
Reputation: 18151
Change your run()
code to
@Override
public void run()
{
Looper.prepare();
// The rest of your code
Looper.loop();
}
Upvotes: 2