-3

I'm developing a phone application and have this function to send an automatic wink (;)) to a specific phone number/contact:

public void onClickWhatsApp(View view) {
    PackageManager pm=getPackageManager();
    String mensajillo =  ";)";
    String toNumber = "xxxxxxxxxxx"; //The xs are replaced with the number which I obtain from other function, but that doesn't matter here
    Intent sendIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:" + "" + toNumber + "?body=" + ""));
    sendIntent.setPackage("com.whatsapp");
    startActivity(sendIntent);
    Intent texintent = new Intent(Intent.ACTION_VIEW);
    texintent.setData(Uri.parse("http://api.whatsapp.com/send?phone="+toNumber +"&text="+mensajillo));
    startActivity(texintent);
}

The thing is that it's just opening the chat and writing the ";)", but not actually sending it. I've been reading for hours and I'm if there's even a way to automatize that. If you know some code that could do what I'm talking about, it would be very welcome ;)

Jorvan
  • 109
  • 2
  • 13
  • And besides: https://www.twilio.com/blog/send-whatsapp-messages-java-applications-twilio-api or https://whatsmate.github.io/2016-02-17-send-whatsapp-message-java/ – Stephen C Sep 07 '19 at 05:16
  • Those seem fine, but isn't there just a way to press the send button by code? Really, that's all what I need now :/ – Jorvan Sep 07 '19 at 18:45
  • https://stackoverflow.com/questions/5701666/can-i-click-a-button-programmatically-for-a-predefined-intent – Stephen C Sep 08 '19 at 02:07
  • I investigated it and I don't find it clear enough how I should add it, can you explain me a bit, pls? – Jorvan Sep 08 '19 at 04:05

1 Answers1

0

Well, at the moment it is impossible. Some people say it would be a pretty big security flaw, so it seems justified

(In any case, sending automatic SMS is pretty easy :P)

Jorvan
  • 109
  • 2
  • 13