Permission required when using Intent to call phone? - android

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?

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
}

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.

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

Related

Which permissions does an Android launcher need to run shortcuts

I am writing an Android launcher that does not support widgets, but it does support shortcuts. One of the shortcuts provided by AOSP is Direct dial, and my launcher needs the android.permission.CALL_PHONE permission for that. My question is, are there any other permissions that I need to add, to allow all possible shortcuts, even those provided by third party apps?
FOR NOUGAT SHORTCUTS ( API LEVEL 25+ )
There is not standard permission to add/launch shortcuts. If target api level of your app is 25+, you can use ShortcutManager or static shortcut via .xml meta-data.
https://developer.android.com/guide/topics/ui/shortcuts.html
FOR LEGACY SHORTCUTS ( BELOW API LEVEL 25 )
If you want to install&use Legacy shortcuts without user interaction, you need to declare INSTALL SHORTCUT permission.
Legacy shortcuts use Intent Action:
Create shortcut for Launcher: "android.intent.action.CREATE_SHORTCUT"
Install shortcut on Launcher: "com.android.launcher.action.INSTALL_SHORTCUT"
Required permission on AndroidManifest.xml:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
You can find more resources when you search for intent actions above.
There is no way to know this in advance. Some apps just assume that the caller of their shortcuts have some permissions (e.g. some system launcher shortcuts often only work in the system launcher itself, as they sometimes require some self defined permission).
In general, any app that offers shortcuts, should run the code in itself instead of the calling app to be sure the required permissions are present, but apparently this is not the case in some apps (especially in launchers e.g.).
I face this problem in an app of mine every now and then as well and catch the exception and tell the user, that the selected shortcut does not support other apps and is implemented in a wrong way.
Example - shortcut to call someone that works and that does not work
E.g. think about a third party app that offers a direct call shortcut. It can handle this in 2 way:
wrong way
It can return an intent like following:
Intent intent = new Intent();
Intent launchIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
...
This intent can ONLY be run by an app that has the action call permission
correct way
The app knows, that the caller may not have the call phone permission, so it does not return the direct phone call intent directly, but a custom one that it handles itself like e.g.
Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.mipmap.icon);
Intent intent = new Intent();
Intent launchIntent = new Intent(this, MyPhoneCallActivity.class);
launchIntent.putExtra("number", number);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(pause != null ? (pause ? R.string.shortcut_pause : R.string.shortcut_resume) : R.string.shortcut_toggle_pause_resume));
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
If the caller executes the shortcut, the MyPhoneCallActivity will be started - this runs inside the app itself and has all permissions of the shortcut provider. This activity then can simply execute the Intent.ACTION_CALL intent itself and finishes itself afterwards. This way, the calling app does not need any special permissions. The workaround via an activity is one solution for this problem that works.
This is not a definitive answer, as I couldn't find this explicitly stated anywhere, but it seems that only phone call shortcuts require a permission, so the CALL_PHONE permission is the only one you need, to launch shortcuts.
AOSP launcher only checks for the CALL_PHONE permission. Source: https://android.googlesource.com/platform/packages/apps/Launcher3/+/master/src/com/android/launcher3/Launcher.java#1630
I haven't been able to find any other types of shortcuts that require permissions.

Usage access settings, permissions

I am trying to use UsageStatsManager. I know that I am supposed to include.
<user-permission android:label="PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/>.
I also started an intent for the user to allow usage access.
Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
startActivity(intent);
But my app does not show up in the Apps with usage access list in the settings.
Screenshot
I need to know why my app is not showing up in that list?
Your tag is misspelled. its supposed to be <uses-permission/> instead of <user-permission/> RIP

How to choose third party dials before making a call in android

I have implemented how to make a call in android, it working now but I need choose option before making call if any third party dials app is available in my phone, is it possible do this,
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + "mobilePhone"));
context.startActivity(intent);
As a measure of security android does not allow dialing app, i mean you can design your own dialing app and contacts etc but you can only go as far as "dialing the number", all calling etc is done by the system own app
if you want to build the app you need only call this
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:The telephone number to call"));
startActivity(callIntent);
After this android will take over control and make the call
Do not forget the permission:
<uses-permission android:name="android.permission.CALL_PHONE">

Options for Skype / Dialer when calling from app

I am creating an application from which the user can call people. In this application I would like to give the option of using either the phone's dialer or other VOIP applications such as Skype or Lync (which incidentally are both Microsoft software). My only problem is that they don't seem to be registered to listen for android.intent.action.CALL (this gives me the phone), but only for android.intent.action.CALL_PRIVILEGED - via which I cannot reach the phone's dialer (I'm guessing that's the privileged part). I'm developing on a stock Nexus 4 btw.
Is there a pretty way that I can launch my intent and be given the option of both the dialer and also Skype/Lync?
Right now my calling the intent looks like this:
Uri numberUri = Uri.parse("tel:" + number);
final Intent intent = new Intent("android.intent.action.CALL_PRIVILEGED");
intent.setData(numberUri);
mContext.startActivity(intent);
Feel free exchange the contents of the intent for Intent.ACTION_CALL - I'm doing it all the time at the moment.
Sorry Dear this cannot be possible.

Android limit CALL_PHONE permission to avoid hidden calls

The Android docs for the CALL_PHONE permission reads:
"Allows an application to initiate a phone call without going through the Dialer
user interface for the user to confirm the call being placed."
Also this message is prompted to the user when he installs the app.
Reading that the application may start hidden calls can possibly discourage installation for some users.
Since my app does NOT start hidden calls, I wonder if there is a way to limit this behaviour, possibly with a more strict permission, to avoid displaying that dreadful message to the user.
Here is my corrected solution:
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:" + 1234));
startActivity(callIntent);
This doesn't require any permissions and just open the dialer. Should be exactly that what you were looking for.
I don't think it's possible. There are 2 permissions associated with phone calls (CALL_PHONE, CALL_PRIVILEGED) with CALL_PHONE being the less restrict one. Google Play will always show that discouraging description for any application holding these permissions.
If this permission is really important for your application, leave it as it is. But opening the dialer instead of calling is a much better option for the user experience (In most of the cases), so try using it instead (You said you're notifying the user anyway... So why can't you show the dialer instead of that notification?)

Categories

Resources