mouser58907
mouser58907

Reputation: 797

android.permission.CALL_PHONE for tablets

I am developing an app and in the manifest I have:

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

When I click on the button to execute this code:

Intent intentcall = new Intent();
intentcall.setAction(Intent.ACTION_CALL);
intentcall.setData(Uri.parse("tel:" + phonenumber)); // set the Uri
startActivity(intentcall);

It will run fine on phones, and on tablets it pops up with a display where you can view or add the number to contacts. However, if I keep the permission in the manifest, it isn't available for tablets in the market. How can I keep the code behavior and still have it display in the market for tablets as well as phones?

Upvotes: 39

Views: 57100

Answers (5)

valerybodak
valerybodak

Reputation: 4413

Try to use Intent.ACTION_DIAL instead Intent.ACTION_CALL.

For example:

try {
   Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone_number));
   startActivity(intent);
} catch (Exception e) {
    //TODO smth       
}

And in this case you can completely remove these tags from AndroidManifest.xml:

<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" />

Upvotes: 40

Kevin TeslaCoil
Kevin TeslaCoil

Reputation: 10097

In the AndroidManifest you need:

<uses-feature android:name="android.hardware.telephony" android:required="false" />

The CALL_PHONE permission implies telephony is required, but if you specify that is not you won't be filtered.

Upvotes: 63

Bush
Bush

Reputation: 2533

From google docs:

Declared elements are informational only, meaning that the Android system itself does not check for matching feature support on the device before installing an application

usage is only for google play

Upvotes: 0

user655489
user655489

Reputation: 1326

Regarding "uses-feature" and it crashing - are you checking that telephony is available before actually making the call? It might be you need to do that extra step for the case when the app is on tablets. All you are saying in the manifest is that the feature is not required. It probably relies on you to actually implement the logic around that.

Upvotes: 6

John Leehey
John Leehey

Reputation: 22240

Instead of adding a user with the ACTION_CALL identifier, change it to ACTION_INSERT_OR_EDIT.

You'll need these permissions too, instead of the CALL_PHONE permission:

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

Take a look at this related question:

can't find app on market

Upvotes: 3

Related Questions