1

I want to write an Android App that analyses chats. For each messenger, for each contact, I want to get a list of all messages sent and received (since installing my app). The key thing here, is that I want the list of messages to be in order. My app should support as many messengers as possible. What would be the best way to do this?

I researched and found a few ways to access messengers' messages:

  • Using accessibility services (Related: How to read window content (using accessibilityService) and evoking UI using draw over other app permission in Android?)
    • to read the screen content of other apps that is annotated with accessibility labels
    • caveats:
      • the messenger needs to have accessibility implemented correctly
      • I have to filter which text blobs are relevant
  • Using NotificationListenerService

    • to get the content of notifications for received messages
    • caveats:
      • only gets content of messages for which there was a notification
      • except for their time, there is no order of the messages given
  • taking screenshots and doing optical character recognition

    • caveats:
      • probably insane

When I get the messages, I still have to order them. For this, I think, the accessibility services are my best bet as I could use the date information on screen in most messages, and also their position on the screen.

However, there is still an edge case. As I understand it, accessibility services can only see the content currently on the screen. The user might also use another device to chat while the device with the app installed is powered off. Thus, once the device with the app installed is powered on again, the app might not be able to see the old messages written while the device was powered off (until the user scrolls up again).

Are my assumptions correct? Do you know of a better way for my app to read/sort the messages?

Matthias
  • 737
  • 8
  • 14

0 Answers0