我创建了使用 Microsoft Translator API 翻译文本的示例 Android 应用程序。我包含了来自这个项目的 jar 文件https://github.com/boatmeme/microsoft-translator-android-test。这是我的应用程序代码...
public class translateSample extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Translate.setClientId("my client key");
Translate.setClientSecret("client secret key");
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_translate);
Button Trans1 = (Button)findViewById(R.id.translate);
Trans1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText Input = (EditText)findViewById(R.id.input);
EditText Output = (EditText)findViewById(R.id.output);
String In =Input.getText().toString();
//String Out;
try
{
String Out = Translate.execute(In, Language.ENGLISH, Language.FRENCH);
Input.setText(Out);
Output.setText(Out);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
我收到以下错误:
java.lang.Exception: [microsoft-translator-api] Error retrieving translation : Hostname <datamarket.accesscontrol.windows.net> was not verified
请帮我解决这个错误。