8

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?

Harald Wilhelm
  • 6,656
  • 11
  • 67
  • 85

3 Answers3

23

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
}
jobbert
  • 3,297
  • 27
  • 43
android developer
  • 114,585
  • 152
  • 739
  • 1,270
13

Is this really required?

Yes.

I do not understand the difference between a phone and a camera feature.

Phone calls can cost people money. Hence, if you directly place a phone call (vs. ACTION_DIAL to just put the number in the dialer), Android wants the user to agree ahead of time to allow this.

Taking pictures with the camera does not usually directly cost users any money.

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

Not really.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Stumbled on this answer by chance now. Should it be updated (the last part) with the following link: http://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference ? – Shaihi Jun 17 '12 at 16:08
  • 1
    @Shaihi: Not really. The OP was really asking what `Intent` actions imply certain permissions, which is not covered by the link you supplied. – CommonsWare Jun 17 '12 at 16:11
  • @CommonsWare I think Intent.ACTION_CALL will work without CALL_PHONE permission. but for ACTION_DIAL permission is required. – droidev May 09 '18 at 09:19
  • @droidev: You have that backwards. `ACTION_DIAL` does not require a permission, because it does not actually place a phone call. `ACTION_CALL` does require a permission. – CommonsWare May 09 '18 at 10:18
  • @CommonsWare Yes, perfect – droidev May 09 '18 at 11:29
1

When you issue a request to the camera, it merely opens an app requiring user interaction before it can do anything.

Phone calls open an app with the phone number already entered so you merely just have to press a button.

There's a much higher risk that you'll accidentally call someone than if you were to accidentally take a picture (Which you could just delete if taken accidentally.)

Andrew Neely
  • 908
  • 11
  • 19
Ben
  • 60,438
  • 111
  • 314
  • 488