title: ScheduledExecutorThread only executing once when making callback to Dart Plugin
body: <p><strong>Flutter  Plugin Help</strong></p>
  <p>I'm currently working on an example plugin that retrieves wifi information from the network currently connected to on the mobile device. I am using Flutter and created the boilerplate for the app through the flutter terminal commands.</p>
  <p>The problem I am having is when I attempt to make a callback to Dart via Java using .invokeMethod(method, args). The Executor service seems to only be running once and then stopping. Is there something I am doing wrong here I cannot seem to find an answer online?</p>
  <p>Below is my Java code.</p>
  <pre><code>@Override
    public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result) {
  
      class SendInfo implements Runnable {
        @Override
        public void run() {
          System.out.println(&quot;Runnable operation invoked &quot; + String.valueOf(count) + &quot; times.&quot;);
          count++;
          WifiManager wifiManager = (WifiManager) appContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
          String ssid = wifiManager.getConnectionInfo().getSSID();
          int strength = wifiManager.getConnectionInfo().getRssi();
          Map&lt;String, Integer&gt; args = new HashMap&lt;&gt;();
          args.put(ssid, strength);
          System.out.println(args);
          channel.invokeMethod(&quot;receiveInfo&quot;, args);
        }
      }
  
      if (call.method.equals(&quot;getSSID&quot;)) {
        String ssid = getInfo().getSSID();
        result.success(ssid);
      } else if (call.method.equals(&quot;getStrength&quot;)){
        String strength = String.valueOf(getInfo().getRssi());
        result.success(strength);
  
      } else if (call.method.equals(&quot;start&quot;)){
        System.out.println(&quot;Start method invoked.&quot;);
        ScheduledFuture&lt;?&gt; ssidFuture = executorService.scheduleAtFixedRate(new SendInfo(), 0, 1, TimeUnit.SECONDS);
      } else if (call.method.equals(&quot;stop&quot;)){
  
      }
      else {
        result.notImplemented();
      }
  </code></pre>
  <p>Here is the the Dart side of the plugin, for now I am simply just trying to print the retrieved values before anything else. Another problem is that Dart cannot seem to match up the received call.method with the provided String, and seems to skip the switch statement altogether.</p>
  <pre><code>class StatHandler {
    static const MethodChannel _channel = const MethodChannel('WifiStats');
  
    void init() {
      _channel.setMethodCallHandler(_callbackHandler);
      print(&quot;Method Channel set.&quot;);
      start();
    }
  
    Future&lt;String&gt; getSSID() async {
      final String name = await _channel.invokeMethod('getSSID');
      print(name);
      return name;
    }
  
    Future&lt;String&gt; getStrength() async {
      final String strength = await _channel.invokeMethod('getStrength');
      print(strength);
      return strength;
    }
  
    void start() {
      _channel.invokeMethod('start');
    }
  
    void stop() {
      _channel.invokeMethod('stop');
    }
  
    Future&lt;dynamic&gt; _callbackHandler(MethodCall call) {
      var callback = call.arguments;
      var method = call.method;
      print(&quot;Method Call: &quot; + method);
  
      switch (call.method) {
        case &quot;receiveInfo&quot;:
          // handle data
          print(&quot;&lt;SSID, Strength&gt;: &quot; + callback);
          return callback;
          break;
        default:
          throw UnsupportedError(&quot;Error&quot;);
      }
    }
  }
  </code></pre>