ciginfo Well-Known Member Licensed User Longtime User Oct 8, 2020 #1 Hi, The code below to send SMS works very well on most smartphones but on some numbers such as Honor 10 from Huawei it crashes the application. Should I use another code or modify this one? Thank you B4X: Copy Sub ImgSms_Click MessageURI= "Ceci est un exemple " Dim i As Intent i.Initialize(i.ACTION_VIEW,"") i.SetType("vnd.android-dir/mms-sms") i.PutExtra("address", "")) i.PutExtra("sms_body", MessageURI) StartActivity(i) End Sub
Hi, The code below to send SMS works very well on most smartphones but on some numbers such as Honor 10 from Huawei it crashes the application. Should I use another code or modify this one? Thank you B4X: Copy Sub ImgSms_Click MessageURI= "Ceci est un exemple " Dim i As Intent i.Initialize(i.ACTION_VIEW,"") i.SetType("vnd.android-dir/mms-sms") i.PutExtra("address", "")) i.PutExtra("sms_body", MessageURI) StartActivity(i) End Sub
Erel B4X founder Staff member Licensed User Longtime User Oct 8, 2020 #2 StartActivity will throw an exception if there is no installed app that can handle the intent. You can catch this error with Try / Catch. This is not a standard intent. You should use instead: https://www.b4x.com/android/forum/threads/send-sms-from-b4a-code.117898/#content Upvote 0
StartActivity will throw an exception if there is no installed app that can handle the intent. You can catch this error with Try / Catch. This is not a standard intent. You should use instead: https://www.b4x.com/android/forum/threads/send-sms-from-b4a-code.117898/#content
ciginfo Well-Known Member Licensed User Longtime User Oct 9, 2020 #3 Erel said: StartActivity will throw an exception if there is no installed app that can handle the intent. You can catch this error with Try / Catch. This is not a standard intent. You should use instead: https://www.b4x.com/android/forum/threads/send-sms-from-b4a-code.117898/#content Click to expand... I went to the page https://www.b4x.com/android/forum/threads/send-sms-from-b4a-code.117898/#content but I still don't see how to fix the problem? Upvote 0
Erel said: StartActivity will throw an exception if there is no installed app that can handle the intent. You can catch this error with Try / Catch. This is not a standard intent. You should use instead: https://www.b4x.com/android/forum/threads/send-sms-from-b4a-code.117898/#content Click to expand... I went to the page https://www.b4x.com/android/forum/threads/send-sms-from-b4a-code.117898/#content but I still don't see how to fix the problem?
Erel B4X founder Staff member Licensed User Longtime User Oct 11, 2020 #4 Use this intent to send SMS: Code: Copy Dim In As Intent In.Initialize(In.ACTION_VIEW, "sms:" & number) 'better to URLEncode the number with StringUtils, In.PutExtra("sms_body", "this is the body") StartActivity(In) Upvote 0
Use this intent to send SMS: Code: Copy Dim In As Intent In.Initialize(In.ACTION_VIEW, "sms:" & number) 'better to URLEncode the number with StringUtils, In.PutExtra("sms_body", "this is the body") StartActivity(In)