I coded program about dictionary sentence and I want to have function to go to \"google translator\" application in my app
How can I use it , Should I import anything?
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);