Search code examples
javaandroidrootwhatsapp

How to get received whatsapp messages programmatically?


What is the best way to get whatsapp messages in the moment messages are received. Is the easiest way to read the notifications of the phone or is there a better way? Root permissions are allowed.


Solution

  • I may have 2 solutions:

    1. Check every x seconds for unread messages and save the id of this message. Next time check again for unread messages which have an id higher than the previous one. Then the app knows which message is new and can read all new ones.

    2. Use AccessibilityService to get notificated when a new message from whatsapp was received and follow the same steps.

    Tell me if it helped or if it's a bad idea :D