title: Add a call button to an Android App
body: <p>I'm trying to add a call button. Which would be button14. All the other buttons open a WebActivity file that has the strings as links in it.  </p>
  
  <p>I'm real new to programming in Android. I had someone help me create the app in the first place but he is out of town and I need to get this done. Any help would be great!! </p>
  
  <pre><code>package com.myapp.programname;
  
  import com.myapp.programname.R;
  
  import android.net.Uri;
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.View;
  
  public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      public void onButton(View view) {
  
          int index = -1;
          int id = view.getId();
  
          if (id == R.id.button1) {
  
              index = 0;
          }
          else if (id == R.id.button2) {
  
              index = 1;
          }
          else if (id == R.id.button3) {
  
              index = 2;
          }
          else if (id == R.id.button4) {
  
              index = 3;
          }
          else if (id == R.id.button5) {
  
              index = 4;
          }
          else if (id == R.id.button6) {
  
              index = 5;
          }
          else if (id == R.id.button7) {
  
              index = 6;
          }
          else if (id == R.id.button8) {
  
              index = 7;
          }
          else if (id == R.id.button9) {
  
              index = 8;
          }
          else if (id == R.id.button10) {
  
              index = 9;
          }
          else if (id == R.id.button11) {
  
              index = 10;
          }
          else if (id == R.id.button12) {
  
              index = 11;
          }
          else if (id == R.id.button13) {
  
              index = 12;
          }
          else if (id == R.id.button14) {
  
              Intent callIntent = new Intent(Intent.ACTION_CALL);
              callIntent.setData(Uri.parse("tel:123456789"));
              startActivity(callIntent);
          }
  
          else {
  
              index = 0;
          }
  
          Intent intent = new Intent(this, WebActivity.class);
          intent.putExtra("link", index);
          this.startActivity(intent);
      }
  }
  </code></pre>
  
  <p>Here is the WebActivity Code Also</p>
  
  <pre><code>package com.myapp.programname;
  
  import com.myapp.programname.R;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  public class WebActivity extends Activity {
  
      private class MyWebViewClient extends WebViewClient{
  
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
  
              return false;
          }
      }
  
      String links[] = {"http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com,
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com",
              "http://somesite.com"};
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_web);
  
          int index = getIntent().getIntExtra("link", 0);
          WebView myWebView = (WebView) findViewById(R.id.webview);
          myWebView.getSettings().setJavaScriptEnabled(true);
          myWebView.getSettings().setLoadWithOverviewMode(true);
          myWebView.getSettings().setUseWideViewPort(true);
          myWebView.getSettings().setBuiltInZoomControls(true);
          myWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
          myWebView.setWebViewClient(new MyWebViewClient());
          myWebView.loadUrl(links[index]);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.web, menu);
          return true;
      }
  
  }
  </code></pre>