Update FM UI after service bind complete
On activity start, bind service callback can be delayed and is received after
activity life cycle i.e after onResume(). Because of the delay, UI
update won't happen. Hence update FM user interface, i.e. RDS, frequency etc.,
if service callback received or retry once after 100ms.
CRs-Fixed: 1090643
Change-Id: Icef5922c3e3972f5e44cd1d3f873f864785e26be
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 7d357f7..1da839b 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -505,16 +505,25 @@
super.onResume();
- if (!isAntennaAvailable()) {
+ if (mService == null) {
+ Log.d(LOGTAG,"bind callback has not received yet - wait for 100ms");
+ mHandler.postDelayed(UpdateFm, 100);
return;
}
- // TODO: We should return on exception or continue?
- try {
- if (mService != null)
- mService.registerCallbacks(mServiceCallbacks);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
+ 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");
@@ -559,7 +568,8 @@
mUpdatePickerValue = true;
updateStationInfoToUI();
enableRadioOnOffUI();
- }
+ }
+ };
private static class LoadedDataAndState {
public LoadedDataAndState(){};
public boolean onOrOff;