Permission required when using Intent to call phone?

半世苍凉 提交于 2019-12-23 07:46:06

问题


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?


回答1:


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.




回答2:


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:

startActivity( new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + PhoneNumber)));



回答3:


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.)



来源:https://stackoverflow.com/questions/8041347/permission-required-when-using-intent-to-call-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!