title: Making a call when button pressed on Arduino
body: <p>Hi I'm trying to combine 2 projects
  1. that tells me wen button on arduino pressed
  2. make a call on android</p>
  
  <p>what im trying to do is when button pressed on arduino make a call..
  but with no luck :(</p>
  
  <p>Call</p>
  
  <pre><code>    package net.mitchtech.adb;
  
      import net.mitchtech.adb.simpledigitalinput.R;
      import android.app.Activity;
      import android.content.ActivityNotFoundException;
      import android.content.Intent;
      import android.net.Uri;
      import android.os.Bundle;
      import android.util.Log;
  
      public class phonecalls extends Activity {
  
      private void call() {
          try {
              Intent callIntent = new Intent(Intent.ACTION_CALL);
              callIntent.setData(Uri.parse("tel:048598077"));
              startActivity(callIntent);
          } catch (ActivityNotFoundException activityException) {
              Log.e("dialing-example", "Call failed", activityException);
          }
      }
  
          /** Called when the activity is first created. */
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.input);
          }
      }
  </code></pre>
  
  <p>buttons</p>
  
  <pre><code>package net.mitchtech.adb;
  
  import net.mitchtech.adb.simpledigitalinput.R;
  import net.mitchtech.adb.phonecalls;
  
  import org.microbridge.server.AbstractServerListener;
  import org.microbridge.server.Server;
  
  import android.content.Context;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.widget.FrameLayout;
  import android.widget.TextView;
  
  public class ButtonView extends FrameLayout {
      private static final String TAG = ButtonView.class.getSimpleName();
  
      private final View mButtonView;
  
      private Server mServer;
  
      private final int BUTTON1 = 2;
      private final int BUTTON2 = 3;
  
      public ButtonView(Context context, AttributeSet attrs) {
          super(context, attrs);
  
          LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          mButtonView = inflater.inflate(R.layout.input, this);
      }
  
      public void setServer(Server server) {
          mServer = server;
  
          mServer.addListener(new AbstractServerListener() {
  
              @Override
              public void onReceive(org.microbridge.server.Client client, byte[] data) {
                  if (data.length &lt; 2)
                      return;
  
                  final int pinNumber = data[0];
                  final int pinState = data[1];
                  Log.i(TAG, "data[0]:" + pinNumber + "  data[1]:" + pinState);
  
                  final TextView positionText = (TextView) findViewById(R.id.activeText);
  
                  class InputAction implements Runnable {
  
                      public void run() {
  
                          switch (pinNumber) {
                          case BUTTON1:
                              if (pinState == 1) {
                                  call();
                                  positionText.setText("Button 1 Active");
  
                              } else {
                                  positionText.setText("");
                              }
                              break;
                          case BUTTON2:
                              if (pinState == 1) {
                                  positionText.setText("Button 2 Active");
                              } else {
                                  positionText.setText("");
                              }
                              break;
  
                          default:
                              break;
                          }
                      }
                  };
  
                  InputAction action = new InputAction();
                  post(action);
              }
          });
      }
  
      public View getmButtonView() {
          return mButtonView;
      }
  }
  </code></pre>
  
  <p>and another activity</p>
  
  <pre><code>package net.mitchtech.adb;
  
  import java.io.IOException;
  
  import net.mitchtech.adb.simpledigitalinput.R;
  
  import org.microbridge.server.Server;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  
  public class SimpleDigitalInputActivity extends Activity {
  
      private final static String TAG = SimpleDigitalInputActivity.class.getSimpleName();
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.main);
  
          Server server = null;
          try
          {
              server = new Server(4567);
              server.start();
  
              ButtonView buttonView = (ButtonView) findViewById(R.id.inputView);
              buttonView.setServer(server);
              } catch (IOException e)
          {
              Log.e(TAG, "Unable to start TCP server", e);
              System.exit(-1);
          }
      }
  }
  </code></pre>