0

I would like to pre fill a SMS for user who uses facebook messenger. Here you can find my Kotlin code :

val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("sms:" + smsToString)
intent.putExtra("sms_body", provider.getSmsBody())
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val list = context!!.packageManager.queryIntentActivities(intent, 
PackageManager.MATCH_DEFAULT_ONLY)
val context = activity!!.applicationContext
if (list.isNotEmpty()) {
    context.startActivity(intent)
}

This code launch the facebook messenger app with the new sms window, and with the list of contacts prefilled. But, the sms_body is empty. The same code works when the default sms app is Android Messages.

Is there a solution ?

Thanks :)

rompotier
  • 223
  • 2
  • 5
  • Why do you think that facebook messenger looks for the sms_body extra? Does it have any documentation saying it does? – Gabe Sechan Feb 21 '18 at 16:31
  • i am not sure if i understand correctly...do you want to prefill the message when opening the facebook messenger? because that´s not allowed. or do you want to prefill it only if a user uses it as sms provider? – andyrandy Feb 21 '18 at 17:01
  • 1
    I thaught the "sms_body" was a standard for sms app ? It works with Android messages, or the samsung sms app app. – rompotier Feb 21 '18 at 17:12
  • And @luschn, I want to prefill it only if the user uses it as sms provider. – rompotier Feb 21 '18 at 17:13
  • I found that : https://stackoverflow.com/a/26101857/2656581 , that's not the best way but could do the job. – rompotier Feb 21 '18 at 17:14

0 Answers0