diff options
Diffstat (limited to 'fmapp2/src/com/caf/fmradio/FMRadio.java')
-rw-r--r-- | fmapp2/src/com/caf/fmradio/FMRadio.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java index 43fd2ef..1da839b 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadio.java +++ b/fmapp2/src/com/caf/fmradio/FMRadio.java @@ -439,7 +439,7 @@ public class FMRadio extends Activity public void onRestart() { Log.d(LOGTAG, "FMRadio: onRestart"); try { - if (null != mService) { + if (null != mService && isAntennaAvailable()) { mService.requestFocus(); } } catch (Exception e) { @@ -505,13 +505,25 @@ public class FMRadio extends Activity super.onResume(); - // TODO: We should return on exception or continue? - try { - if (mService != null) - mService.registerCallbacks(mServiceCallbacks); - } catch (RemoteException e) { - e.printStackTrace(); + if (mService == null) { + Log.d(LOGTAG,"bind callback has not received yet - wait for 100ms"); + mHandler.postDelayed(UpdateFm, 100); + return; } + mHandler.post(UpdateFm); + } + Runnable UpdateFm = new Runnable() { + public void run() { + // TODO: We should return on exception or continue? + if (!isAntennaAvailable()) { + return; + } + try { + if (mService != null) + mService.registerCallbacks(mServiceCallbacks); + } catch (RemoteException e) { + e.printStackTrace(); + } if (isSleepTimerActive()) { Log.d(LOGTAG, "isSleepTimerActive is true"); @@ -556,7 +568,8 @@ public class FMRadio extends Activity mUpdatePickerValue = true; updateStationInfoToUI(); enableRadioOnOffUI(); - } + } + }; private static class LoadedDataAndState { public LoadedDataAndState(){}; public boolean onOrOff; |