如何设置 Google Cloud Platform 并开始在 Android 应用程序中使用 API?

How to setup Google Cloud Platform and start using API in Android app?

设置Google云平台。想用翻译器API。在连接 App 的步骤停止。 有一个 img 到我的台阶,我有存货

我在 Windows 10 上设置了环境变量。

之后是一段代码

         // If you don't specify credentials when constructing the client, the
        // client library will look for credentials in the environment.

        Storage storage = StorageOptions.getDefaultInstance().getService();

        Page<Bucket> buckets = storage.list();
        for (Bucket bucket : buckets.iterateAll()) {
        // do something with the info
        }

但不明白我应该用它做什么。我的下一步是什么。以及如何将 Google Cloud API 附加到我的应用程序。是不是跟加库一样?

有一个link指南https://cloud.google.com/docs/authentication/getting-started#auth-cloud-implicit-java

有人在 google 云平台中看到 android 的身份验证分步指南吗?

使用翻译 API 的最简单方法是使用 HTTP 请求发送。我认为您应该看到 REST API 引用,并通过您的 API 键发出一个简单的 POST 请求,您就会明白。

后端有使用 Firebase Cloud Function 的教程 here。您只需要创建一个插入实时数据库的 Android 客户端。

或者如果您想直接从 android 客户端调用 url api,您需要一个 api 密钥,可以在 https://console.cloud.google.com/apis/credentials

https://www.googleapis.com/language/translate/v2?key=${apiKey}&source=en&target=${lang}&q=${text}

要在 Android 中调用 api url,您可以使用 Retrofit2FastAndroidNetworking 库。但它不安全,因为您需要将 api 密钥放在客户端源代码中