Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission required when using Intent to call phone?

In one of my apps I'm using the following code to issue a phone call:

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(...)); 
startActivity(intent);

The docs say I do need the following Manifest permission to do so:

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

Is this really required? I do not understand the difference between a phone and a camera feature. When using a phone intent I do need a permission but I don't need permission for a camera intent:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
...
startActivityForResult(intent, 1);

Is there a list on hardware features that need a permission if fired with the help of an intent and those that don't?

like image 977
Harald Wilhelm Avatar asked Nov 07 '11 19:11

Harald Wilhelm


People also ask

Which permission is required for phone call?

In order to make a call, your app needs the CALL_PHONE permission.

How is intent used to dial numbers?

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.


1 Answers

Actually, if you wish to just open the dialer with a specific phone number, without direct calling (needs user confirmation), you can do it without any permission:

Uri uri = Uri.parse("tel:" + PHONE_NUMBER);
Intent callIntent = new Intent(Intent.ACTION_DIAL, uri);
try {
    context.startActivity(callIntent);
} catch (ActivityNotFoundException activityNotFoundException) {
    // TODO: place code to handle users that have no call application installed, otherwise the app crashes
}
like image 147
android developer Avatar answered Sep 27 '22 19:09

android developer