I have the following, common code, in my service:
HandlerThread thread = new HandlerThread(ClientGatewayService.class.getSimpleName());
thread.start();
serviceLooper = thread.getLooper();
In production this works fine, but under Robolectric, the serviceLooper object above is null.
According to
the Android docs, getLooper can return null if the thread has not started or Thread#isAlive() returns false for any reason. In any other case the call to getLooper is supposed to block until the looper is prepared.
Given that I'm calling Thread#start() immediately preceding this, it would imply that the HandlerThread, under Robolectric, it would appear the either the HandlerThread has prepared the looper, run the looper and already killed it. I don't see an instance of HandlerThread in Robolectric shadows, so I assume this is using
the Android source.
Anyone know what's going on here?
--
Jeremy Wadsack