Pregunta

Need help... I am working on transliteration in Android and it requires API_KEY, but as I'm new to Android, I don't know how to get that API_KEY, Can anybody tell me, what I have to do to get that API_KEY...? Thanks in Advance...!! Following is my code snippet---

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);

        }

    };

}
¿Fue útil?

Solución

Follow the following steps,

1) Sign In here with your google account

2) Click on the link developers.google.com [at bottom left]

3) Click on the link API Console [at bottom left]

4) (if this is your first time) The screen will display 'Start using the Google APIs console' and then click on CREATE PROJECT

5)Below the GOOGLE api logo ,click on the drop down list and select CREATE

6)Enter name for your project and click CREATE PROJECT

7) Now activate which ever service you want => i.e. ON the service then check in I agree... and click ACCEPT

8)Click on the API Access [left side] and here is your required API key

or this link can also help you

This one is for GCM service

Otros consejos

You can get API keys on google's website from the google's console (you need to be logged to get it). Here's the link to get the API key for translate : Google API_KEY Translate. If you need more details, you can also check the Developer's guide.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top