I am trying to build an app that translate the current city to english. this is my code:
class translateAsync extends AsyncTask<Void, Integer, Boolean> {
@Override
protected Boolean doInBackground(Void... arg0) {
Translate.setClientId("xxx");
Translate.setClientSecret("yyy");
try {
translatedText = Translate.execute(location, Language.AUTO_DETECT, Language.ENGLISH);
} catch(Exception e) {
translatedText = e.getMessage();
}
return true;
}
}
this is my call to async task:
new translateAsync() {
protected void onPostExecute(Boolean result) {
if (translatedText.contains("Error")){
lblCbProfileLayoutCurrentCity.setText(translatedText);
} else {
lblCbProfileLayoutCurrentCity.setText(getResources().getString(R.string.user_profile_code_current_city)
+ translatedText);
}
Toast.makeText(UserProfileActivity.this, translatedText, Toast.LENGTH_SHORT).show();
}
}.execute();
I keep getting this error:
[microsoft-translator-api] Error retrieving translation: https://datamarket.access-control.windows.net/v2/qauth2-13 Please Help Me.
I found the answer. I didn't register my app in the azure market correctly and because of it i got a wrong secret key. if anyone needs help with registering correctly you can email me.