支持与手机,没有电话功能的Andr​​oid设备功能、电话、设备、手机

2023-09-05 11:18:22 作者:勢力代表壹切

我将运行在具有电话功能,而没有设备的应用程序。下面是我的一些疑问的:

I have an application that will run on devices that have phone capabilities and that don't. Here are some of my queries:

1)我能够同时支持类型的设备。 2)对于具有电话功能的设备,我需要启用通话功能。和不具有电话功能装置i将禁用主叫功能。

1) Will i be able to support both type of devices. 2) For the devices that have phone capabilities, i need to enable calling feature. and the device that do not have phone capabilities i will disable calling functionality.

我不是很清楚的<用户权限>和<用户特征>概念,有没有一种方法来指定电话<使用者-功能>

I am not very clear about the <user-permissions> and <user-features> concept, is there a way to specify phone <user-features>

推荐答案

如果你不是通过市场分配您的应用程序,如果你不关心下面推荐的做法,那么你应该只需要&LT;使用-许可&GT; 标记的应用程序使用任何权限。然而,让正确的设备通过市场准入的应用程序,则需要两个&LT;使用-许可&GT; &LT;使用特征&GT ;。标签

If you're not distributing your app through the Market and if you don't care about following recommended practices, then you should only need <uses-permission> tags for any permissions the app uses. However, to allow the correct devices to access the app through the Market, you will need both <uses-permission> and <uses-feature> tags.

&LT;使用-许可&GT; 是一个请求给你申请的机关采取某种行动。当preparing安装您的应用程序,用户可以查看所请求的权限,并决定是否继续安装。如果应用程序,例如,尝试打个电话不宣布android.permission.CALL_PHONE权限,则尝试将失败。请参见这里为基础平台的权限列表。

<uses-permission> is a request to give your application the authority to take a certain kind of action. When preparing to install your app, the user can review the requested permissions and decide whether to to continue with the installation. If the app, for example, attempts to make a phone call without declaring the "android.permission.CALL_PHONE" permission, then the attempt will fail. See here for a list of base platform permissions.

&LT;使用-许可&GT; 也被市场隐含的功能需求。如果你的应用程序使用,需要电话硬件权限,那么市场将承担电话硬件是必需的,应用程序将无法使用缺少的电话硬件设备。

<uses-permission> is also used by the Market for implicit feature requirements. If your app uses a permission that needs telephony hardware, then the Market will assume telephony hardware is required, and the app will not be available to a device that lacks telephony hardware.

&LT;使用特征&GT; 既可以用于某一个功能的需告知市场的或者特征的是可取的,但不是必需的的。该标签将覆盖&其中隐含的任何功能;采用-许可&GT; 。如果,例如,您可以指定&LT;使用特征的android:NAME =android.hardware.telephony机器人:要求=FALSE/&GT; ,然后电话是没有的要求,不管是什么权限要求。

<uses-feature> can be used to inform the Market either that a certain feature is required or that the feature is desirable but not required. The tag will override any features implied by <uses-permission>. If, for example, you specify <uses-feature android:name="android.hardware.telephony" android:required="false" />, then telephony is not required, regardless of what permissions are requested.

要看看&LT;采用-许可&GT; &LT;使用特征&GT; 互动创造市场过滤器,请参阅here.

To see how <uses-permission> and <uses-feature> interact to create the Market filters, see here.

要在运行时检查功能是否可用,它看起来像你可以使用PackageManager.hasSystemFeature():

To check at run time whether a feature is available, it looks like you can use PackageManager.hasSystemFeature():

Context context;    // Some object, such as Activity, that extends Context
// ...
boolean hasTelephony = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
if (hasTelephony) {
    // ...
}
else {
    // ...
}