Android Question I can send SMS programmatically from one phone but not from other, runtime is included

mare1980k1

Member
Licensed User
Longtime User
It is ZTE blade phone that the msg doesn't work on. On my LGE Nexus 5X it sends SMS without problem.
My manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
   <uses-permission
  android:name="android.permission.SEND_SMS"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)
'End of default text.
AddPermission(android.permission.SEND_SMS)
And the code on main page:
B4X:
Sub Process_Globals
Private rp As RuntimePermissions
End Sub

Sub Activity_Create(FirstTime As Boolean)
If rp.Check(rp.PERMISSION_SEND_SMS)=False Then
     rp.CheckAndRequest(rp.PERMISSION_SEND_SMS)
End If
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
   If Permission = rp.PERMISSION_SEND_SMS Then
       If Result Then
           ToastMessageShow("You have the permission to send SMS.", False)
       Else
           ToastMessageShow("You don't have the permission to send SMS", False)
       End If
   End If
End Sub
And the code on other page:
B4X:
Msgbox(SMStext,phonenumber)
Dim Sms1 As PhoneSms
'Sms1.Send2(phonenumber,SMStext,False,False) ' also doesnt work
Sms1.Send(phonenumber,SMStext)

On the main page first time I uninstall the app and install it asks for the runtime permission and it asks on the phone that works. On the other phone it doesn't ask, but confirms that the app has the permission with the check.

MsgBox displays everything good and it works on one phone but on other it doesn't.

Is there something that I am missing?
Thank you in advance,
Regards
 

mare1980k1

Member
Licensed User
Longtime User
My android version is 5.1. But anyway it works when I changed the target sdk to 22. Thanks Erel! :)
 
Upvote 0
Top