B4A Library USSD

Hello all,

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim myussd As USSDCallBack
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    myussd.Initialize("ussd")
   

    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CALL_PHONE )
    Wait For Activity_PermissionResult(perm As String,res As Boolean)
    If perm=Starter.rp.PERMISSION_CALL_PHONE And res=True Then
        Dim id As InputDialog
        id.InputType=id.INPUT_TYPE_PHONE
        Dim sf As Object = id.ShowAsync("", "Enter USSD", "Ok", "", "Cancel", Null, False)
        Wait For (sf) Dialog_Result(Result As Int)
        If Result = DialogResponse.POSITIVE Then
            Log(id.Input)
        End If
        myussd.sendUssdRequest(id.Input)
    Else
        ToastMessageShow("Permission not granted",False)
    End If
   
End Sub

Sub ussd_onreceiveussdresponse(request As String,response As String)
    Log(response)
    Msgbox(response,request)
End Sub
Sub ussd_onreceiveussdresponsefailed(request As String,failcode As Int)
    Log(failcode)
End Sub
 

Attachments

  • USSDCallBack.zip
    2.6 KB · Views: 789
  • USSDCallBack0.09.zip
    4.9 KB · Views: 4
Last edited:

vinpolins

Member
Hello all,
Hello, thank you for your useful library, and I hope you still work on this project.

Is it possible to add the ability to select SIM to make a USSD request on dual SIM smartphone?

Could you edit the lib for that, or could you share the source code and I will make an edit?
Thank you
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hello, thank you for your useful library, and I hope you still work on this project.

Is it possible to add the ability to select SIM to make a USSD request on dual SIM smartphone?

Could you edit the lib for that, or could you share the source code and I will make an edit?
Thank you
Can you test the new version ? 0.09
It is now attached to the original post .
something like this for testing :
B4X:
For Each si As SubscriptionInfo In myussd.ActiveSubscriptionInfoList
        Log(si.CarrierName&" "&si.SubscriptionId )
        myussd.sendUssdRequestForSubscription("*142#", si.SubscriptionId)
    Next

B4X:
AddPermission(android.permission.READ_PHONE_STATE)
 
Last edited:
Top