0

I have an unknown number I need to start chat with it.

        Intent intent = new Intent();
        intent
                .setAction(Intent.ACTION_SEND)
                .putExtra(Intent.EXTRA_TEXT, "test")
                .putExtra("jid", "999999999@s.whatsapp.net")
                .setType("text/plain")
                .setPackage("com.whatsapp");

        activity.startActivity(intent);

Whatsapp openы a window where I have to select a contact.

Is it possible to open Whatsapp and start a chat with it?

Evgeny Naumov
  • 347
  • 1
  • 4
  • 15

1 Answers1

1

I found an answer here

String phone = "79999999999";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("whatsapp://send?phone=" + phone));
startActivity(intent);

Phone should be without any characters only digits. This number is valid 79999999999, this number is not valid +79999999999

Evgeny Naumov
  • 347
  • 1
  • 4
  • 15