0

My application need to copy text from any application in the device which is currently in use. For an example, if skype is open, then it should perform an operation like CTRL+A+C in PC, so the text will be copied to my app/clipboard.

I know this can be done via programatically taking a screenshot and performing OCR, but interested in knowing whether there is any direct way as mentioned before.

I am open for either Android (Java) solutions or NDK solutions.

Note: No Rooting is allowed.

PeakGen
  • 21,894
  • 86
  • 261
  • 463

1 Answers1

1

Fortunately, this is not possible in general, for blindingly obvious privacy and security reasons.

You are welcome to write an accessibility service or an assistant (latter is Android 6.0+). These can give you access to text in TextViews, content descriptions of ImageViews, and so on. However, they require extra configuration on the user's behalf, and those users are warned about the privacy and security implications of activating your app.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • wow, this sounds cool. `These can give you access to text in TextViews, content descriptions of ImageViews, and so on` - Does this mean accessing other apps? – PeakGen Feb 10 '16 at 13:01
  • @Tracer: Yes, at least whatever is in the foreground. The accessibility APIs are designed for helping people navigate a UI who may have difficulty doing so using normal means (e.g., Talkback-style audio assistance for the visually impaired). – CommonsWare Feb 10 '16 at 13:05
  • oh, great. can I also edit the text in those text fields (like, change their colour or making links like `skype click to call` addon in web browsers do? – PeakGen Feb 10 '16 at 16:43
  • Also, can you please give any link for these where I can study? – PeakGen Feb 10 '16 at 16:45
  • @Tracer: "I also edit the text in those text fields" -- absolutely not. – CommonsWare Feb 10 '16 at 17:00
  • Thank you. Meanwhile, since you have great knowledge on Android, I would like to bring the following question to your attention. Please have a look - http://stackoverflow.com/questions/35173978/how-to-execute-both-speech-recognition-and-audio-recording-at-the-same-time – PeakGen Feb 11 '16 at 04:54