Margaruga / JavaWhatsApp

Send and listen messages through WhatsApp from a Java Program.
33 stars 25 forks source link

Message Listening does not working. #2

Open sadiqodho opened 8 years ago

sadiqodho commented 8 years ago
  boolean run = true;

    Client.init("/usr/bin/python", "JavaWhatsApp/yowsup/yowsupclient.py");

    while (run) {

        Client.ListenIncomingMessages();

        ArrayList<Contact> unreaden = Client.getUnseenContacts();

        if (!unreaden.isEmpty()) {

            for (Contact ur : unreaden) {

                String from = ur.getNumber();
                String text = ur.getUnseenMessage();

                System.out.println(from + "-" + text);

                if (text.equals("stop")) {
                    Client.killit();
                    run = false;
                    break;
                }
            }

        } else {
            System.out.println("There are not new messages");
        }
    }

When I try to send message from my Whatsapp to device. there is no message received. But yowsup python api does work fine. Anyone to find out reason.