Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
send whatsapp message to given number in code with give pre-specified text on click of FloatingActionButton Whatsapp

Below is the code & Error is: When i click on button, it takes me to market place as in the playstore to install whatsapp but whatsapp is already installed. I want to open Whatsapp of the number given in the code with specified text.

//whatsapp code
    fab_whatsapp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String smsNumber = "918291332142";
            boolean isWhatsappInstalled = whatsappInstalledOrNot ("com.whatsapp");
            if (isWhatsappInstalled)
            {
                Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                String url = "https://api.whatsapp.com/send?phone=" + "918291332142" + "&text=" + "Hello World!";
                sendIntent.setType("text/plain");
                sendIntent.putExtra(Intent.EXTRA_TEXT, "Hi, this is a test message");
                sendIntent.setPackage("com.whatsapp");
                startActivity(sendIntent);
            }else {
                Toast.makeText(MainActivity.this, "Whatsapp not Installed", Toast.LENGTH_SHORT).show();
                Uri uri = Uri.parse("market://details?id=com.whatsapp");
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(goToMarket);
            }
        }
    });

private boolean whatsappInstalledOrNot(String uri) {
    PackageManager pm = getPackageManager();
    boolean app_installed = false;
    try {
        pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
        app_installed = true;
    } catch (PackageManager.NameNotFoundException e) {
        app_installed = false;
    }
    return app_installed;
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!