In Android we can make Phone calls to a particular Phone Number using Intents.
android.permission.CALL_PHONE
You need to write <uses-permission android:name="android.permission.CALL_PHONE" /> in order to make a call
You will use ACTION_CALL action to trigger built-in phone call functionality available in Android device. Following is simple syntax to create an intent with ACTION_CALL action
You can use ACTION_DIAL action instead of ACTION_CALL, in that case you will have option to modify hardcoded phone number before making a call instead of making a direct call.
Permission Required
android.permission.CALL_PHONE
You need to write <uses-permission android:name="android.permission.CALL_PHONE" /> in order to make a call
You will use ACTION_CALL action to trigger built-in phone call functionality available in Android device. Following is simple syntax to create an intent with ACTION_CALL action
Intent phoneIntent = new Intent(Intent.ACTION_CALL);
You can use ACTION_DIAL action instead of ACTION_CALL, in that case you will have option to modify hardcoded phone number before making a call instead of making a direct call.
To make a phone call at a given number 91-000-000-0000, you need to specify tel: as URI using setData() method as follows −
phoneIntent.setData(Uri.parse("tel:91-000-000-0000"));a
Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:0377778888")); if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } startActivity(callIntent);
No comments:
Post a Comment