Beja Expert Licensed User Longtime User Mar 30, 2024 #1 Hi all, Trying to invoke whatsapp but it didn't work, anyone has an idea why? This is the code that I used. the B4A sub was generated by AI Code: Sub OpenWhatsApp Try Dim i As Intent i.Initialize(i.ACTION_VIEW, "https://api.whatsapp.com") i.SetPackage("com.whatsapp") StartActivity(i) Catch ToastMessageShow("WhatsApp not Installed", True) End Try End Sub Edit: The required action is to open the WhatsApp App on the phnone, not the WhatsApp website URL
Hi all, Trying to invoke whatsapp but it didn't work, anyone has an idea why? This is the code that I used. the B4A sub was generated by AI Code: Sub OpenWhatsApp Try Dim i As Intent i.Initialize(i.ACTION_VIEW, "https://api.whatsapp.com") i.SetPackage("com.whatsapp") StartActivity(i) Catch ToastMessageShow("WhatsApp not Installed", True) End Try End Sub Edit: The required action is to open the WhatsApp App on the phnone, not the WhatsApp website URL
Sagenut Expert Licensed User Longtime User Mar 30, 2024 #2 B4X: Dim in As Intent Dim pm As PackageManager in = pm.GetApplicationIntent("com.whatsapp") StartActivity (in) You also need to add this in the Manifest B4X: AddManifestText( <queries> <package android:name="com.whatsapp"/> </queries> ) Upvote 0
B4X: Dim in As Intent Dim pm As PackageManager in = pm.GetApplicationIntent("com.whatsapp") StartActivity (in) You also need to add this in the Manifest B4X: AddManifestText( <queries> <package android:name="com.whatsapp"/> </queries> )
sirjo66 Well-Known Member Licensed User Longtime User Mar 30, 2024 #3 if you want only open whatsapp the source code above is perfect, but if you want also open a chat on a number and send a message: Code: Dim i As Intent in.Initialize(in.ACTION_VIEW, $"whatsapp://send?phone=${Cell}&text=${Testo}"$) StartActivity(in) where Cell is phone number (without "+") and Testo is the message "URLencoded UTF8" Last edited: Mar 30, 2024 Upvote 0
if you want only open whatsapp the source code above is perfect, but if you want also open a chat on a number and send a message: Code: Dim i As Intent in.Initialize(in.ACTION_VIEW, $"whatsapp://send?phone=${Cell}&text=${Testo}"$) StartActivity(in) where Cell is phone number (without "+") and Testo is the message "URLencoded UTF8"