fix crash by not creating Handler until on UI thread

Receiver is created and installed by a non-UI thread sometimes so can't
create the Handler there. onReceive() is called on an ok thread however
so create it there on demand. Fixes crash that showed when receiving
relay messages in background.
This commit is contained in:
Eric House 2018-12-05 20:17:13 -08:00
parent 390370c07a
commit ba95432e44

View file

@ -181,8 +181,6 @@ public class NetStateCache {
public PvtBroadcastReceiver()
{
// DbgUtils.assertOnUIThread(); // firing
mHandler = new Handler();
mLastStateSent = s_netAvail;
}
@ -191,6 +189,11 @@ public class NetStateCache {
{
DbgUtils.assertOnUIThread();
if ( null == mHandler ) {
DbgUtils.assertOnUIThread();
mHandler = new Handler();
}
if ( intent.getAction().
equals( ConnectivityManager.CONNECTIVITY_ACTION)) {