0

I'm creating my own InputMethod (IME). When the user is typing a message to a contact using my IME, I would like to retrieve the contact's info and its attributes.

Or, rephrase, how to get the info on the Contact on screen?

( Can my app communicate with the messaging app on screen and get the Contact? )

Note: I can write attributes to the contacts. I'm thinking of retrieving those too.

elcool
  • 6,041
  • 7
  • 29
  • 44

1 Answers1

0

Can my app communicate with the messaging app on screen and get the Contact?

No. From within your IME, you can get info about the field that you are currently editing.

how to get the info of the Contact on screen?

Using AccessibilityService.

An accessibility service runs in the background and receives callbacks by the system when AccessibilityEvents are fired. Such events denote some state transition in the user interface, for example, the focus has changed, a button has been clicked, etc. Such a service can optionally request the capability for querying the content of the active window. Development of an accessibility service requires extending this class and implementing its abstract methods.

Prasad Pawar
  • 1,606
  • 1
  • 15
  • 30