启用 API
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需在您自己的应用中使用 Tuning Fork 库,请在 Google Cloud 控制台中启用 Android Performance Parameters API。需要 Google 开发者账号才能创建 Google Cloud Console 项目。
您可以使用现有的 Google Cloud Console 项目(例如,您为演示版应用创建的项目)。请按照以下步骤向现有项目添加适当的 API 密钥限制。
步骤
请按以下步骤启用 API:
在 Google Cloud Console 中,转到 Projects 页面。选择一个现有项目,或新建一个项目。
转到“Projects”页面
如需详细了解如何创建 Google Cloud Console 项目,请参阅 Cloud API 文档。
在您选定的项目中启用 Android Performance Parameters API。
启用 API
如果尚未启用,请点击 ENABLE。
选择左侧的 Credentials 标签页。
如果项目尚无 API 密钥,请点击 CREATE CREDENTIALS,然后选择 API Key。
图 1. 创建 API 密钥
将 API 密钥复制到游戏项目 tuningfork_settings.txt
文件的 api_key
字段中。
将 API 密钥限制为仅适用于 Android 应用:
- 您应该会看到 Key restrictions 部分。如果没有,请双击 API 密钥。
- 在 Application restrictions 下,选择 Android apps。
- 点击 ADD AN ITEM。
- 输入应用的软件包名称。
输入 SHA-1 证书指纹以对您的应用进行身份验证。使用发布证书指纹:
keytool -exportcert -list -v \
-alias your-key-name -keystore path-to-production-keystore
图 2. 将密钥限制为仅适用于 Android 应用
将 API 密钥限制为用于 Android Performance Parameters API:
- 在 API restrictions 下,选择 Restrict key。
- 从列表中选择 Android Performance Parameters API。
图 3. 将密钥限制为用于 Android Performance Parameters API
请务必点击 Save 以启用限制。
隐私权
请查看您应用的隐私权政策,确保它准确反映与设备和设备使用相关的数据可能会与 Google 共享。您对 Android Performance Parameters API 的使用受 3.b 条 Google API 服务条款的约束,根据该条款规定,您必须:
“遵守所有适用的隐私权法律法规,包括适用于个人身份信息的法律法规。您应提供并遵守您的 API 客户端隐私权政策,其中清晰准确地向您的 API 客户端用户说明,您会收集哪些用户信息,您如何使用此类信息,以及您如何与 Google 及第三方共享此类信息(包括用于广告)。”
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-26。
[null,null,["最后更新时间 (UTC):2025-08-26。"],[],[],null,["To use the Tuning Fork library in your own app, enable the Android\nPerformance Parameters API in the Google Cloud Console. You need a Google\ndeveloper account to create a Google Cloud Console project.\n\nYou can use an existing Google Cloud Console project\n(for example, the one you created for the demo app). Follow\nthe steps below to **add the proper API key restrictions** to your existing\nproject.\n\nSteps\n\nFollow these steps to enable the API:\n\n1. In the Google Cloud Console, go to the **Projects** page. Select an\n existing project or create a new project.\n\n [Go\n to the Projects Page](https://console.cloud.google.com/project)\n\n For more information on creating a Google Cloud Console project, see the\n [Cloud API documentation](https://cloud.google.com/apis/docs/getting-started).\n2. Enable the Android Performance Parameters API on the project you selected.\n\n [Enable\n the API](https://console.cloud.google.com/apis/api/performanceparameters.googleapis.com/overview)\n\n If it has not been enabled, click **ENABLE**.\n3. Select the **Credentials** tab on the left.\n\n4. If the project does not have an existing API key, click **CREATE\n CREDENTIALS** and select **API Key**.\n\n\n **Figure 1.** Create an API key\n5.\n Copy the API key into the `api_key` field in the game project\n `tuningfork_settings.txt` file.\n\n6. Restrict the API key to Android apps only:\n\n 1. You should see a **Key restrictions** section. If not, double-click the API key.\n 2. Under **Application restrictions** , select **Android apps**.\n 3. Click **ADD AN ITEM**.\n 4. Enter your app's package name.\n 5. Enter the SHA-1 certificate fingerprint to\n [authenticate your app](https://developers.google.com/android/guides/client-auth).\n Use the release certificate fingerprint:\n\n ```\n keytool -exportcert -list -v \\\n -alias your-key-name -keystore path-to-production-keystore\n ```\n\n\n **Figure 2.** Restrict the key to Android apps only\n7. Restrict the API key to the Android Performance Parameters API:\n\n 1. Under **API restrictions** , select **Restrict key**.\n 2. Select **Android Performance Parameters API** from the list.\n\n\n **Figure 3.** Restrict the key to the Android Performance Parameters API\n8. Make sure to click **Save** to enable the restrictions.\n\nPrivacy\n\nReview your app's Privacy Policy to ensure that it appropriately reflects that\ndata about devices and usage may be shared with Google. Under Section 3.b the\n[Google APIs Terms of Service](https://developers.google.com/terms), which\ngoverns your use of the Android Performance Parameters APIs, you must:\n\n\"comply with all applicable privacy laws and regulations including those\napplying to PII. You will provide and adhere to a privacy policy for your API\nClient that clearly and accurately describes to users of your API Client what\nuser information you collect and how you use and share such information\n(including for advertising) with Google and third parties.\""]]