The initial idea is to connect or have an application Android
so you can interact with WhatsApp
(for example, send text to WhatsApp, activate or deactivate functions for a specific user ect).
I searched for some API
for this task but I could not find any, and the one I found was perhaps abandoned ( link ) and it is not official.
Is there an official API for this?
On the other hand, the alternative that I am using is the following one (for sending text):
After looking this link (in English)
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
More or less it would be something like this:
public void enviarMsgApp(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent .setType("text/plain");
String texto = "Mensaje para enviar aqui";
intent .setPackage("com.whatsapp");
if (intent != null) {
intent .putExtra(Intent.EXTRA_TEXT, texto);
startActivity(Intent.createChooser(intent, texto));
} else {
Toast.makeText(this,"Nooo whatsapp, whatsapp man",
Toast.LENGTH_SHORT)
.show();
}
}
There is an alternative to be able to modify the "behavior" of WhatsApp on a user.
For example, something like telling the application (which is being created) the name of the user, and this application can make changes to that user. for example change the photo shown, mute etc, although for this have to request permissions from the user or that the same WhatsApp
alert the user that it is trying to make an adjustment and this has to authorize it or something like that.
Pseudo code:
public void cambiarFotoApp(View view, String nombreUsuario) {
//..
Intent intent = new Intent(Intent.ACTION_SEND);
//..
intent .setPackage("com.whatsapp");
//..
//cambiarFoto(nombreUsuario, jpgNuevaFoto);
}