B4A Library SetResultdata (Broad Cast Receiver)

hi with this broadcastreceiver library you can setresultdata to make app like speedcall and ...

i hope this library help you
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim pbr As BCR
End Sub
Sub Service_Create
pbr.addaction("android.intent.action.NEW_OUTGOING_CALL")
pbr.registerreciver
End Sub

Sub Service_Start (StartingIntent As Intent)

End Sub

Sub received (RI As Object)
Dim rii As Intent = RI
    Log(rii.ExtrasToString)
pbr.result = FormatNumber(<any thing you want>)
End Sub

Sub Service_Destroy
pbr.unregisterreceiver
End Sub

Sub FormatNumber(n As String) As String
   Dim r As Reflector
   Return r.RunStaticMethod("android.telephony.PhoneNumberUtils", "formatNumber", _
     Array As Object(n), Array As String("java.lang.String"))
End Sub
 

Attachments

  • BCR.zip
    2.5 KB · Views: 226

ohaco

New Member
Licensed User
Longtime User
Hi mohsen, I’m trying to use this library but it seems that the "Sub received (RI As Object)" is not trigged, is needed to specify in anywhere that this routine will attend the broadcast events?, do I need to add somthing in the manifest?


Thanks
 

mohsen nasrabady

Active Member
Licensed User
Longtime User
hi
i used this lib in a service for speedcall and worked
theese permission used

AddPermission(android.permission.CALL_PRIVILEGED)
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)
AddPermission(android.permission.CALL_PHONE)

u want to use this lib for what?
 

viljemto

Member
Licensed User
Longtime User
Permissions that are necessary for never Android

AddPermission(android.permission.CALL_PRIVILEGED)
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)
AddPermission(android.permission.CALL_PHONE)
AddPermission(android.permission.WRITE_CALL_LOG)

and...

B4X:
    For Each RTPermission As String In Array (rp.PERMISSION_PROCESS_OUTGOING_CALLS, rp.PERMISSION_CALL_PHONE, rp.PERMISSION_WRITE_CALL_LOG)
        rp.CheckAndRequest(RTPermission)
        Wait For Activity_PermissionResult (Permission As String, result As Boolean)
        If Not(result) Then
            ToastMessageShow($"${Permission} not granted..."$, True)
            Log($"${Permission} not granted..."$)
        Else
            Log($"${Permission} is granted..."$)
        End If
        '        Wait For Activity_Resume '<-- wait for Activity_Resume
    Next
 
Last edited:
Top