title: How to make a call programmatically in android
body: <p>I want to make/receive  calls periodically for testing purposes from my android app programmatically and collects stats from my network. So my app will call a number every so often and when the call is answered the app will terminate the call after a few seconds.  TO begin with here is the code I understood would work. It will dial and a call the number I specify without me having to touch the screen.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  int MY_PERMISSIONS_REQUEST_CALL_PHONE = 101;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      call();
  }
  
  private void call() {
  
      try {
  
          Intent callIntent = new Intent(Intent.ACTION_CALL);
          callIntent.setData(Uri.parse("tel:2125551212"));
          System.out.println("====before startActivity====");
  
  
  
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) !=
                  PackageManager.PERMISSION_GRANTED) {
  
              ActivityCompat.requestPermissions(this,
                      new String[]{Manifest.permission.CALL_PHONE},
                      MY_PERMISSIONS_REQUEST_CALL_PHONE);
  
              return;
          }
  
          startActivity(callIntent);
          System.out.println("=====getcallActivity==="+getCallingActivity());
  
  
      } catch (ActivityNotFoundException e) {
          Log.e("helloAndroid","Call failed",e);
      }
  }
  
  }
  </code></pre>
  
  <p>The manifest has this line:
  </p>
  
  <p>As per my understanding ACTION_CALL should place the call to the number I have provided without having to press the DIAL button. But is acting like ACTION_DIAL, which displays the number on the screen and the user then has to press DIAL button to place the call.  So is there  no difference between ACTION_DIAL and ACTION_CALL?</p>
  
  <p>After reading some of the posts I understand that 6.0 onwards permission is needs to be requested from the user to dial the call(which I have used in my code above) </p>
  
  <p>My question is if I use Lollipop(5.0) OS then will I be able to place the call without dialing?</p>