How to use google translator app

From what I can tell, the Google Translate Android app does not expose any standard Intents that you could use (it's a pitty, but it's weird at the same time. You'd think Google would encourage this type of interaction between apps.. anyway).

However, it seems Google have opened up the translate API via a web service. This way, you can do the translation yourself and show it within your app. It's a bit more work, but it should do the job.

You could look at google-api-translate-java if you want to spare yourself from writing an API wrapper.


I have the same problem. Initially, I tried to use Google Translate Ajax API, but since Google have deprecated API version 1 and make version 2 as paid service, my code stops working. Then, I decompiled Google Translate App, looked into the Smali code and got some hint about the logic inside it. Use this code, it works for me:

private void callGoogleTranslateApps(String word, String fromLang, String toLang) {
    Intent i = new Intent();

    i.setAction(Intent.ACTION_VIEW);
    i.putExtra("key_text_input", word);
    i.putExtra("key_text_output", "");
    i.putExtra("key_language_from", fromLang);
    i.putExtra("key_language_to", toLang);
    i.putExtra("key_suggest_translation", "");
    i.putExtra("key_from_floating_window", false);

    i.setComponent(new ComponentName("com.google.android.apps.translate", "com.google.android.apps.translate.TranslateActivity"));
    startActivity(i);
}

Phi Van Ngoc's answer was fantastic, thanks for that.

However it didn't work initially for me and after investigating the Translate apk, it looks like they've modified their file structure slightly, so the intent ComponentName should now be:

i.setComponent(
    new ComponentName(
        "com.google.android.apps.translate",
        "com.google.android.apps.translate.translation.TranslateActivity"));

The difference is that "translation" has been added before "TranslateActivity"

So my final version, including hard-coded translation from Spanish to English, is:

Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.putExtra("key_text_input", "Me gusta la cerveza");
i.putExtra("key_text_output", "");
i.putExtra("key_language_from", "es");
i.putExtra("key_language_to", "en");
i.putExtra("key_suggest_translation", "");
i.putExtra("key_from_floating_window", false);
i.setComponent(
    new ComponentName(
        "com.google.android.apps.translate",
        "com.google.android.apps.translate.translation.TranslateActivity"));
startActivity(i);