title: How to call a service method in a broadcastreceiver?
body: <p>So, I have an app that starts a service. This service starts to scan for bluetooth devices with BTAdapter.startDiscovery(). Further I have a broadcastreceiver which listens for the DISCOVERY_FINISHED action. If that occurs I want to call a method from onReceive() in my service that starts the scanning process again. How am I gonna do this?</p>
  
  <p>Here my receiver:</p>
  
  <pre><code>public class PollingReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          ScanBTService sBTs = new ScanBTService();
          sBTs.startScan();
      }
  }
  </code></pre>
  
  <p>and here the service:</p>
  
  <pre><code>public class ScanBTService extends IntentService {
  
      private BluetoothAdapter mBTAdapter;
      private PollingReceiver mPollingReceiver;
  
      public ScanBTService() {
          super("ScanBTService");
      }
  
      @Override
      protected void onHandleIntent(Intent intent) {
          final BluetoothManager btManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
          mBTAdapter = btManager.getAdapter();
          mBTAdapter.startDiscovery();
      }
  
      public void startScan() {
          try {
              Thread.sleep(10000);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
  
          mBTAdapter.startDiscovery();
      }
  }
  </code></pre>