-1

Is it possible to get "other app's" selected text? Want to created an translation service. When called, the service will automatically translate the selected text in the front app.

If not possible for non-rooted devices, is it possible for rooted devices.

WeiHung
  • 109
  • 2
  • 10

2 Answers2

1

On Android 6.0+, the appropriate way to do this is to support ACTION_PROCESS_TEXT. This will add your app to the floating action menu that appears when the user selects text, and the user can elect to launch your activity to let you translate that text. Note that Google themselves already has an app (Translate) that does this.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
-1

Only if you're the keyboard. Otherwise there's no API for this.

I'm actually toying with doing something similar- my plan was to do it as an accssebility service. So the user would tap on something, we'd get the description from that app, and then translate the description. Basically a screen reader that does translation.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127