I'm trying to use Microsoft Translator for an Android app but it keeps throwing the same exception of "access":

"**java.lang.Exception: [microsoft-translator-api] Error retrieving translation : datamarket.accesscontrol.windows.net**"

Basically I'm running it on Android 2.3, I'm using the Java API ( https://code.google.com/p/microsoft-translator-java-api/ ), and I have registered for the translator in the Windows Azure Marketplace ( https://datamarket.azure.com/developer/applications/register ).

My core code is the following

    Translate.setClientId("MY CLIENT ID");
    Translate.setClientSecret("MY CLIENT SECRET"); 

    try {
        String translatedText = Translate.execute(word, Language.ENGLISH, Language.PORTUGUESE);
        tvTranslation.setText(translatedText);
    }
    catch (Exception e) {
        tvTranslation.setText(e.getMessage());
    }

I even downloaded and ran this project, but got the same error: https://github.com/boatmeme/microsoft-translator-java-api

And this as well: http://mycodeandlife.wordpress.com/2013/02/05/android-tutorials-language-translator-app/

Any ideas? I spent the whole day on it and couldn't get anywhere.

有帮助吗?

解决方案

This was very basic, but I found out the error was due to the (lack of the) Internet permission on Android.

Just needed to add it to my manifest:

<uses-permission android:name="android.permission.INTERNET"/>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top