I'm trying to make Microsoft Translator API in my Java application. I registered in Windows Azure market place and I registered my Microsoft Translate application so I have these ClientId and Client Secret keys but still it doesn't work.
I've added the library JAR to the build path, so I don't think that it would disappear suddently.
everything OK but i have some errors that says i need a dependency library called "json-simple", then i go to here: http://code.google.com/p/json-simple/downloads/list and download the latest version(1.1.1) and import it to my project by right click on my project and click on "build path" and then click on "add external archives" and import it on my project... every thing is OK right now and i don't have any error...
I can't find what I am doing wrong.
Here is my code:
package com.iman.marashi.dictionary;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.iman.marashi.dictionary.G;
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class BingActivity extends Activity {
EditText MyInputText;
ImageView MyTranslateButton;
TextView MyOutputText;
ImageView btnCleare;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bing_search);
MyInputText = (EditText) findViewById(R.id.editText1);
MyOutputText = (TextView) findViewById(R.id.textView1);
MyTranslateButton = (ImageView) findViewById(R.id.TranslateButton);
this.btnCleare = (ImageView) findViewById(R.id.imageView1);
// ///////////////////////////////////////////
MyTranslateButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String InputString;
String OutputString;
InputString = MyInputText.getText().toString();
try {
Translate.setClientId("myID");
Translate
.setClientSecret("MySecret");
OutputString = Translate.execute(InputString,
Language.ENGLISH, Language.PERSIAN);
} catch (Exception e) {
e.printStackTrace();
OutputString = "خطاي اتصال";
}
MyOutputText.setText(OutputString);
}
});
btnCleare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
MyInputText.setText("");
G.hideSoftKeyboard(BingActivity.this);
}
});
}}
But I get this Errors in Logcat ↓
10-16 11:42:48.996: E/AndroidRuntime(3092): FATAL EXCEPTION: main
10-16 11:42:48.996: E/AndroidRuntime(3092): java.lang.NoClassDefFoundError: com.memetix.mst.language.Language
10-16 11:42:48.996: E/AndroidRuntime(3092): at com.iman.marashi.dictionary.BingActivity$1.onClick(BingActivity.java:42)
10-16 11:42:48.996: E/AndroidRuntime(3092): at android.view.View.performClick(View.java:4204)
10-16 11:42:48.996: E/AndroidRuntime(3092): at android.view.View$PerformClick.run(View.java:17355)
10-16 11:42:48.996: E/AndroidRuntime(3092): at android.os.Handler.handleCallback(Handler.java:725)
10-16 11:42:48.996: E/AndroidRuntime(3092): at android.os.Handler.dispatchMessage(Handler.java:92)
10-16 11:42:48.996: E/AndroidRuntime(3092): at android.os.Looper.loop(Looper.java:137)
10-16 11:42:48.996: E/AndroidRuntime(3092): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-16 11:42:48.996: E/AndroidRuntime(3092): at java.lang.reflect.Method.invokeNative(Native Method)
10-16 11:42:48.996: E/AndroidRuntime(3092): at java.lang.reflect.Method.invoke(Method.java:511)
10-16 11:42:48.996: E/AndroidRuntime(3092): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-16 11:42:48.996: E/AndroidRuntime(3092): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-16 11:42:48.996: E/AndroidRuntime(3092): at dalvik.system.NativeStart.main(Native Method)