title: Dynamic value updates from a bound service
body: <p>I'm implementing a bound service that an activity can access via binding. I call methods of the service to get access to particular values. The service gets values updates every 30 millis with a Timer.scheduleAtFixedRate calls to the update method. </p>
  
  <p>I'm expecting that with binding, updated values of the service will be pushed to activity and result in automatic updating of my activity values with only one call; but this is not the case. </p>
  
  <p>Alternatively, I put the service method call in a runnable class and post it using a Handler object. However, even so, the values are not updated. </p>
  
  <p>The connection onCreate():</p>
  
  <pre><code>mConnection = new ServiceConnection(){
  
          @Override
          public void onServiceConnected(ComponentName name, IBinder service) {
              // TODO Auto-generated method stub
  
              Toast.makeText(context, "Service is connected", Toast.LENGTH_SHORT).show();
              LocalBinder binder = (LocalBinder) service;
              gyroService = binder.getService();
              mBound = true;
          }
  
          @Override
          public void onServiceDisconnected(ComponentName name) {
              // TODO Auto-generated method stub
              Toast.makeText(context, "Service is disconnected", Toast.LENGTH_SHORT).show();
              mBound = false;
          }
      };
  </code></pre>
  
  <p>Here's the binding onStart of my activity method.</p>
  
  <pre><code>@Override
  protected void onStart() {
      super.onStart();
      // Bind to LocalService
      Intent gyroIntent = new Intent(this, GyroFusionService.class);
      Bundle bundle = new Bundle();
      bundle.putString("activity", "calibration");
      gyroIntent.putExtras (bundle);
      bindService(gyroIntent, mConnection, Context.BIND_AUTO_CREATE);
  }
  </code></pre>
  
  <p>Here's the runnable object I call using a handler:</p>
  
  <pre><code>private Runnable updateTiltTask = new Runnable() {
      public void run() {
          if (mBound) { 
              // Call a method from the LocalService.
              // However, if this call were something that might hang, then this request should
              // occur in a separate thread to avoid slowing down the activity performance.
              calibValues = ((GyroFusionService) gyroService).getCalibArray();
              baseValues = ((GyroFusionService) gyroService).getBaseArray();
              updateOrientationDisplay(); // on click, update the textView values
              //                  Toast.makeText(context, "received both arrays", Toast.LENGTH_SHORT).show();
  
          }
          else 
              mPitchView.setText("Please wait. Service is not connected yet.");       
          }
  };
  </code></pre>
  
  <p>I know the scheduled timer is working for sure, because on clicking a button in my activity class, I can get updated values from the service, but I do not know how to call or receive value updates from my service class on a regular basis. </p>
  
  <p>My question can be summed up as: </p>
  
  <p>Q1: What is existing mechanisms for getting value updates from bound services?
  Q2: Is a push from service or a pull from activity more efficient for receiving value updates from a bound service? -in this case sensor updates?</p>
  
  <p>Thanks for your time =)  </p>