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?
To add the above answers:
it is important that you pass two-letter language codes. With 3-letter codes, it may look like the google translate app does not receive any data.
In addition, if Intent.ACTION_VIEW
does not work, you can use Intent.ACTION_SEND
.
intent = new Intent();
//intent.setAction(Intent.ACTION_VIEW); // this did not work for me initially
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, m_text);
intent.putExtra("key_text_input", m_text);
intent.putExtra("key_text_output", "");
intent.putExtra("key_language_from", m_language);
intent.putExtra("key_language_to", lang_to);
intent.putExtra("key_suggest_translation", "");
intent.putExtra("key_from_floating_window", false);
intent.setComponent(
new ComponentName(
"com.google.android.apps.translate",
"com.google.android.apps.translate.HomeActivity"
));
//try {
startActivityForResult(intent, REQUEST_CODE_TRANSLATE);
//...