Phi Van Ngoc answer was fantastic, thanks for that.
However, at first this did not work for me, and after studying the Translate apk, it seems that they slightly changed the structure of their files, so now the name ComponentName should be:
i.setComponent( new ComponentName( "com.google.android.apps.translate", "com.google.android.apps.translate.translation.TranslateActivity"));
The difference is that before the translation of "TranslateActivity" a "translation" was added
So my final version, including the hard-coded translation from Spanish to English, is as follows:
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);
nickspoon
source share