2017-10-12 55 views
0

設置Google雲端平臺。想要使用它的翻譯API。在連接App的步驟上採樣。 有一個IMG我的步驟,其中IM放養 enter image description here如何設置Google Cloud Platform並開始在Android應用中使用API​​?

我已經在我的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附加到我的應用。它與剛添加庫類似嗎?

有一個鏈接,引導https://cloud.google.com/docs/authentication/getting-started#auth-cloud-implicit-java

難道有人看到一步一步的在谷歌雲平臺指南權威性的Android?

回答

2

有一個使用Firebase雲端功能的教程,用於後端here。你只需要創建一個插入到實時數據庫的Android客戶端。

或者,如果您想直接從Android客戶端調用URL 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 API密鑰,您可以使用Retrofit2FastAndroidNetworking庫。但它不會安全,因爲您需要將您的api密鑰放入客戶端源代碼

0

使用Translate API的最簡單方法是使用HTTP請求發送。我認爲你應該看到REST API的引用,以及你的API密鑰的簡單POST請求。

相關問題