Google 驱动器 API 清单权限

Google Drive API Manifest Permissions

这并不是什么大问题。我有一个 Android 应用程序将用户密码存储在 SQLite 数据库中。所以上周我启动了一个更新,允许用户将这些密码导出到他们的 Google 驱动器。为此,我使用了 Google Drive Android API。我没有向应用程序清单 (AndroidManifest.xml) 添加任何特殊权限,它工作正常(在 KitKat4.4 上测试)。但是我的一个朋友告诉我它可能无法在 Android 6.0+ 上运行,因为我应该总是请求权限。但我检查了一些样本,其中 none 个样本对清单具有这些权限。大家觉得有必要加权限吗?也许互联网或 GET_ACCOUNTS?

如果您使用 Android 遵循驱动器 API 上的教程,您将在 Step 4:Prepare the project 中看到您需要在代码中添加以下权限。

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

如果您希望您的应用程序 connect/perform 网络操作,则使用 "android.permission.INTERNET" 权限。

对于"android.permission.GET_ACCOUNTS",在documentation中声明:

Note: Beginning with Android 6.0 (API level 23), if an app shares the signature of the authenticator that manages an account, it does not need "GET_ACCOUNTS" permission to read information about that account. On Android 5.1 and lower, all apps need "GET_ACCOUNTS" permission to read information about any account.

有关 meaning/uses 或 android 权限的更多信息,请查看此 page

如果您使用的是 Google Drive Android API,则不需要 INTERNETGET_ACCOUNTS 权限。

The API automatically handles previously complex tasks such as offline access and syncing files. This allows you to read and write files as if Drive were a local file system.

查看 GitHub 上的官方 Quickstart and the demos 示例。其中 None 个在 AndroidManifest.xml 中拥有特殊权限。

但是 如果您将 Google Drive REST API 用于 Android 那么您肯定需要 INTERNET 许可。

根据Google Maps API documentationINTERNETACCESS_NETWORK_STATE权限将自动合并到项目的清单中,这意味着您不必自己指定它们,只要调用API 超过 Google 播放服务。
但是找不到 Google 驱动器 API 的相同描述。