需要帮助...我正在Android中进行音译,它需要API_KEY,但由于我是Android新手,我不知道如何获取API_KEY,谁能告诉我,我必须做什么才能得到那个API_KEY...?提前致谢...!!以下是我的代码片段---
public class MainActivity extends Activity
{
EditText myInputText;
Button myTranslateButton;
TextView myOutputText;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myInputText = (EditText)findViewById(R.id.inputText);
myTranslateButton = (Button)findViewById(R.id.translateButton);
myOutputText = (TextView)findViewById(R.id.outputText);
myTranslateButton.setOnClickListener(MyTranslateButtonOnClickListener);
}
private Button.OnClickListener MyTranslateButtonOnClickListener
= new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
String InputString;
String OutputString = null;
InputString = myInputText.getText().toString();
try
{
GoogleAPI.setHttpReferrer("http:\\www.google.com");
**// Here I need API_KEY**
**GoogleAPI.setKey(" API KEY");**
OutputString = Translate.DEFAULT.execute(InputString,Language.ENGLISH, Language.HINDI);
}
catch (Exception ex)
{
ex.printStackTrace();
OutputString = "Error";
}
Typeface customF = Typeface.createFromAsset(getAssets(), "akshar.ttf");
//final TextView textV = (TextView) findViewById(...);
myOutputText.setTypeface(customF);
myOutputText.setText(OutputString);
}
};
}