Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending message through WhatsApp By intent

How I can send massage from my app to Special number in whatsapp , I know this code to share massage to group or contact on whatsapp

Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "Sorry For Interruption,I'm Just Trying Something";
waIntent.setPackage("com.whatsapp");

if (waIntent != null) {
    waIntent.putExtra(Intent.EXTRA_TEXT, text);//
    startActivity(Intent.createChooser(waIntent,"Share with"));

but I want send massage to Special number like "966xxxxxxx" how I can do that ?

like image 716
Abdullah AlHazmy Avatar asked Jul 21 '13 03:07

Abdullah AlHazmy


People also ask

How can I send intent on WhatsApp?

Like most social apps on Android, WhatsApp listens to intents to share media and text. Simply create an intent to share text, for example, and WhatsApp will be displayed by the system picker: Intent sendIntent = new Intent(); sendIntent.

Can I automate sending of WhatsApp messages?

Sure! We only need to install a library called pywhatkit. Then we can schedule messages to send to any of our contacts or even to a group. Here are the 3 steps you need to follow to send WhatsApp messages to contacts and groups using Python.

Can I use WhatsApp API to send message?

Install the WhatsApp Business API Client — Install your API client. Once your client is working, you can update your application settings. Start using the client — Register your phone number with an API call to /account and send a test message with a call to /messages .

How can I send WhatsApp message without opening app?

Step 1: Open Google App from the Google folder or app drawer. Say “Ok Google” or tap the microphone button as shown. Now, speak “Send it” to send the message that you have spoken.


1 Answers

this is a Solution :

private void openWhatsApp(String id) {

Cursor c = getSherlockActivity().getContentResolver()
            .query(ContactsContract.Data.CONTENT_URI,
                  new String[] { ContactsContract.Contacts.Data._ID },  
                  ContactsContract.Data.DATA1 + "=?",
                  new String[] { id }, 
                  null);

c.moveToFirst();
Intent i = new Intent(Intent.ACTION_VIEW, 
              Uri.parse(
                   "content://com.android.contacts/data/" +           
                    c.getString(0)));

startActivity(i);
c.close();
}

Where id is what's app uri like [email protected]

like image 79
Abdullah AlHazmy Avatar answered Sep 23 '22 14:09

Abdullah AlHazmy