You could create an Android Library (you can read more about at Creating an Android Library with Kotlin for use with Xojo) and use the following Kotlin code:
fun sendMessage(con: Any?, message: String?) {
val newCon: Context
if (con is Context)
newCon = con
else
throw NullPointerException()
// Creating intent with action send
val intent = Intent(Intent.ACTION_SEND)
// Setting Intent type
intent.type = "text/plain"
// Setting whatsapp package name
intent.setPackage("com.whatsapp")
// Give your message here
intent.putExtra(Intent.EXTRA_TEXT, message)
try {
intent.setFlags(FLAG_ACTIVITY_NEW_TASK)
// startActivity wants a context parameter before the indent parameter
startActivity(newCon, intent, null)
} catch (e: ActivityNotFoundException) {
// Define what your app should do if no activity can handle the intent.
}
}
And the Xojo Declare should look kind like this:
Declare Sub sendMessage Lib "com.example.utility.regex" (context As Ptr, message As CString)
sendMessage(App.AndroidContextHandle, "Hello World")
Give it a try, not tested, but should be the way to go.