send messege to whatsapp business app with an unsaved contact number

58 Views Asked by At

I need to open Whatsapp to chat with a unsaved contact number, but I can't achieve this in android version 13 on Redmi android device programmatically

I tried below code,

val uri = Uri.parse("smsto:$toNumber")
var intent = Intent(Intent.ACTION_SENDTO, uri)
intent.setPackage("com.whatsapp.w4b")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
startActivity(intent)

then I use below code but I can't send media(image,video), I want send message(text,image,video)

val url =
    "https://api.whatsapp.com/send?phone=" + toNumber.toString() + "&text=" + Uri.parse(
        "Text that you want to send to the current user"
    )
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))

Kindly share if possible to achieve this

Thanks in advance !!!

0

There are 0 best solutions below