mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
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:
parent
68ae9790b4
commit
051aeba57c
1 changed files with 5 additions and 2 deletions
|
@ -181,8 +181,6 @@ public class NetStateCache {
|
||||||
|
|
||||||
public PvtBroadcastReceiver()
|
public PvtBroadcastReceiver()
|
||||||
{
|
{
|
||||||
// DbgUtils.assertOnUIThread(); // firing
|
|
||||||
mHandler = new Handler();
|
|
||||||
mLastStateSent = s_netAvail;
|
mLastStateSent = s_netAvail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +189,11 @@ public class NetStateCache {
|
||||||
{
|
{
|
||||||
DbgUtils.assertOnUIThread();
|
DbgUtils.assertOnUIThread();
|
||||||
|
|
||||||
|
if ( null == mHandler ) {
|
||||||
|
DbgUtils.assertOnUIThread();
|
||||||
|
mHandler = new Handler();
|
||||||
|
}
|
||||||
|
|
||||||
if ( intent.getAction().
|
if ( intent.getAction().
|
||||||
equals( ConnectivityManager.CONNECTIVITY_ACTION)) {
|
equals( ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue