如何要求 android.permission.CALL_PHONE 但仍然安装在平板电脑上?

How to ask for android.permission.CALL_PHONE but still install on tablet?

我有一个刚刚发布到 Play 商店的应用程序,当我尝试从没有电话功能的平板电脑访问它时,它显示为 "This app is incompatible with all of your devices"。它在实际 Android phones.

上安装得很好

事情是这样的 - 我们希望用户能够在平板电脑和其他没有 phone 的设备上安装该应用程序,并且只是让 telephone 功能不起作用.但是,如果我在清单中包含 CALL_PHONE 权限,Play 商店将不允许安装它。

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

如何让 Google Play 允许请求 CALL_PHONE 权限的应用安装在没有 phone 的设备上?

您可以指定电话是可选的:

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

documentation 说:

The table below lists permissions that imply feature requirements equivalent to those declared in elements. Note that declarations, including any declared android:required attribute, always take precedence over features implied by the permissions below.

For any of the permissions below, you can disable filtering based on the implied feature by explicitly declaring the implied feature explicitly, in a element, with an android:required="false" attribute. For example, to disable any filtering based on the CAMERA permission, you would add this declaration to the manifest file:

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

在您的情况下,table 的相关部分是:

Cateegory   This permission...     Implies This Feature Requirement 
Telephony   CALL_PHONE             android.hardware.telephony
            CALL_PRIVILEGED        android.hardware.telephony
            MODIFY_PHONE_STATE     android.hardware.telephony
            PROCESS_OUTGOING_CALLS android.hardware.telephony
            READ_SMS               android.hardware.telephony
            RECEIVE_SMS            android.hardware.telephony
            RECEIVE_MMS            android.hardware.telephony
            RECEIVE_WAP_PUSH       android.hardware.telephony
            SEND_SMS               android.hardware.telephony
            WRITE_APN_SETTINGS     android.hardware.telephony
            WRITE_SMS              android.hardware.telephony