Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda