Android Question SMS permission

edgar_ortiz

Active Member
Licensed User
Hi,

I'm trying to send a sms:

B4X:
Sub EnviaSMS (ParNumero As String, ParMensaje As String)
    '
    Dim lcSMS As JavaObject
    Dim lcPort As Short = 90
    Dim lcDestination As String = ParNumero
    Dim Data() As Byte = ParMensaje.GetBytes("UTF8")
    '
    lcSMS = lcSMS.InitializeStatic("android.telephony.SmsManager").RunMethod("getDefault", Null)
    lcSMS.RunMethod("sendDataMessage", Array(lcDestination, "", lcPort, Data, Null, Null))
    '
End Sub
And I receive the error:

"Caused by: java.lang.SecurityException: Sending SMS message: User 10093 does not have android.permission.SEND_SMS."


java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:109)
at idsms.id.enviarsms._enviasms(enviarsms.java:382)
at idsms.id.enviarsms._esbutenviar_click(enviarsms.java:431)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Sending SMS message: User 10093 does not have android.permission.SEND_SMS.
at android.os.Parcel.readException(Parcel.java:1322)
at android.os.Parcel.readException(Parcel.java:1276)
at com.android.internal.telephony.ISms$Stub$Proxy.sendData(ISms.java:489)
at android.telephony.SmsManager.sendDataMessage(SmsManager.java:491)
... 22 more
java.lang.reflect.InvocationTargetException
Thanks in advance for your time,

Edgar
 
Top