可选权限,使一个应用程序可以显示在所有设备并启用可选功能上的一些? [英] Optional permissions so an app can show on all devices and enable optional features on some?

查看:150
本文介绍了可选权限,使一个应用程序可以显示在所有设备并启用可选功能上的一些?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的

许多功能都需要一个用途,允许在清单中进行设置。这些值,然后确定哪些设备会看到他们的市场。然而,应该怎样做,如果该功能是可选的...如果它可以作出许多设备上运行,但需要权限只对几个?

举个例子:假设有多个功能的应用程序和内容的一个良好的数额 - 它提供了一个按钮致电该公司。这是一个很好的方便的功能,而不是写下来的数量或复制并粘贴到手机的应用程序。它不是必需的,但是。

如果该功能的使用和电话的权限将被添加到应用程序,那么这一切都很好的手机 - 但没有平板电脑将在市场上看到的应用程序

什么是这个问题的一个通用的解决方案?

多个应用程序可以使用不同的权限进行,但有问题与方法的世界(额外的开发时间,保持维护一致的难度,评论和评级分割到不同的应用程序,如果有几种不同类型的可选权限比不同的应用,可能需要对于每个组合)。

该应用程序可以以编程方式检查功能可用并启用它,或者根据设备上禁用它。这问题是,如果该应用不具有权限,那么它会如果尝试使用该功能崩溃 - 如果它确实有权限,某些设备将不能够找到在该应用市场。

在某些情况下,它可能会切出不必要的特征从该应用完全避免这个问题。这不是一个很好的解决方案要么,因为这些功能将是锦上添花,支持它的设备。

是的,我知道<一个href="http://stackoverflow.com/questions/5712375/is-it-possible-to-have-optional-permissions-in-android">Is有可能有&QUOT;可选&QUOT;在Android权限?是一个类似的问题。我希望的新的信息和人发现了其他解决方法,如果有的话...该如何解决这个问题?有没有人有除了那些我上面列出?其他办法

解决方案
  

什么是这个问题的一个通用的解决方案?

有关具体问题,添加&LT;使用特征的android:NAME =android.hardware.telephony机器人:要求=FALSE/&GT; 您清单,以表明此的功能的可选。然后,您可以使用 PackageManager hasSystemFeature()来确定设备是否具有非所需的功能在运行时。

Many features in Android require a uses-permission to be set in the manifest. These values then determine what devices will see them in the Market. However, what should be done if the feature is optional... if it could be made to run on many devices, but would require the permission only on a few?

An example: let's say an app with multiple features and a good amount of content--and it provides a button to call the company. That's a nice convenient feature, as opposed to writing down the number or copying and pasting it into the phone app. It's not essential, however.

If that feature is used and the telephony permission is added to the app, then that's all well and good for phones--but no tablet would see the app in the Market.

What is a general solution for this problem?

Multiple apps could be made with different permissions, but there's a world of problems with that approach (extra development time, difficulty of keeping maintenance consistent, reviews and ratings split across different apps, and if there are several different types of optional permissions than a different app may be needed for each combination).

The app could programmatically check if the feature is available and enable it or disable it depending on the device. The problem with that is that if the app doesn't have the permission, then it will crash if it tries to use that feature--and if it does have the permission, some devices won't be able to find the app in the Market.

In certain cases, it may be possible to cut out nonessential features from the app entirely to avoid the issue. That's not a great solution either, since those features WOULD be "nice to have" on devices that support it.

Yes, I am aware Is it possible to have "optional" permissions in Android? is a similar question. I'm hoping for newer information and for other workarounds people have found, if any... what is the solution to this issue? Does anyone have other approaches besides the ones I've listed above?

解决方案

What is a general solution for this problem?

For that specific problem, add <uses-feature android:name="android.hardware.telephony" android:required="false"/> to your manifest, to indicate that this feature is optional. You can then use PackageManager and hasSystemFeature() to determine if a device has the non-required feature at runtime.

这篇关于可选权限,使一个应用程序可以显示在所有设备并启用可选功能上的一些?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆