-3

have run the code in my phone or just the "else" condition is working.on running the app just displays the "package is not installed"

"Kotlin"

    val button = findViewById<Button>(R.id.openwhtaspchat)



    button.setOnClickListener {
    val uri = Uri.parse("smsto"+"+923354859491")
        val intent = Intent(Intent.ACTION_SENDTO,uri)
        intent.setPackage("com.whatsapp")
        if (intent.resolveActivity(this.packageManager)!=null){
            startActivity(intent)
        }else{
            Toast.makeText(this,"package is not installed",Toast.LENGTH_SHORT).show()

        }
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 1
    https://stackoverflow.com/q/62535856 – Mike M. Jun 18 '22 at 18:55
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 19 '22 at 11:34

1 Answers1

0

when u wanna send something to specific app use

val intent = Intent(Intent.ACTION_SEND, uri)

i'm using always that metode not this one

val intent = Intent(Intent.ACTION_SENDTO, uri)

i'm not sure about kotlin, i use java but Intent are same i think

SamilYT
  • 46
  • 3