0

make call

I'm trying to make a call through my app. But my app dials number from android mobile dial pad. I want my dial pad in my call. My code is

Uri uri=Uri.parse("tel:"); Intent intent=new Intent();intent.setAction(Intent.ACTION_DIAL);

Thanks

Payal Sorathiya
  • 756
  • 1
  • 8
  • 23

2 Answers2

0

Try this code

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + mobile));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Hope this code helps you.

Shivam Sharma
  • 290
  • 2
  • 14
0

In manifest add this permission:

<uses-permission android:name="android.permission.CALL_PHONE" />

Then in Activity use this :

Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:" + PhoneNO));
            callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            if (ActivityCompat.checkSelfPermission(Activityx.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
                return;
            }
            startActivity(callIntent);
jakir hussain
  • 316
  • 2
  • 18