Android Question Looking for events for a busy phone and for answer by the remote user

Marco Gioia

Member
Licensed User
Hi everbody,
I read (downloaded and tried) almost the entire b4a site looking for a really working example for phoneevents with dual sim calling


This is the code used to call
B4X:
'sim = 0 SIM1, = 1 SIM2
Sub Call_SIM(num As String, sim As Int)
Dim i As Intent
i.Initialize(i.ACTION_CALL, "tel:" & num)
i.putExtra("simSlot", sim)
i.putExtra("com.android.phone.force.slot", True)
i.putExtra("Cdma_Supp", True)
i.putExtra("com.android.phone.extra.slot", sim)
StartActivity(i)
End Sub
Can you help me?

Thanks in advance
 
Last edited:

Marco Gioia

Member
Licensed User
Ok... if so I can change to a single sim
Is there somewhere a working example?
I need to call sequentially about five numbers (conference call) and re-call several time if one of them is busy
 

Marco Gioia

Member
Licensed User
Ok, but which is the event have I to intercept for a busy phone?
I need to know to put it in a queue and recall the number at the end of the sequence.
 

Marco Gioia

Member
Licensed User
Complicated or impossible, for b4a?

The native app of my smartphone intercepts these events

is there an expert who can solve this issue? (I can pay, obviously it depends on the price)


upload_2019-3-20_21-48-29.png
 

peacemaker

Well-Known Member
Licensed User
@Marco Gioia,
Android does not allow to detect that the call is answered. Answer machine is impossible.
You can only make call, and kill it.


B4X:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    Main.PhoneState = State

    'Log("State=" & State)
    'Log(Intent.ExtrasToString)
    
    If State = "RINGING" AND IncomingNumber<>"" Then 'incoming call
        Main.LastInNumber = IncomingNumber
        PhoneFlag = 1
        'Log("Incoming detected " & DateTime.Time(DateTime.Now))
        DoEvents
        'ToastMessageShow("Calling " & IncomingNumber, True)
        Return
    End If
    If State = "OFFHOOK" AND IncomingNumber="" AND PhoneFlag = 1 Then 'answering to incoming call
        PhoneFlag = 2
        Return
    End If
    If State = "OFFHOOK" AND IncomingNumber="" AND PhoneFlag = 0 Then    'outgoing call
        Main.LastInNumber = IncomingNumber
        PhoneFlag = 4
        WaitingTimer.Enabled = True
        Log("PhoneFlag = 4, out call")
        'AR.Start
        Return
    End If
    If State = "IDLE" AND Main.LastInNumber <> "" AND PhoneFlag = 2 Then 'just income call finished
        PhoneFlag = 3
        Return
    End If
    If State = "IDLE" AND Main.LastInNumber <> "" AND PhoneFlag = 1 Then 'just rejected income call
        PhoneFlag = 0
        Return
    End If
    If State = "IDLE" AND PhoneFlag = 4 Then 'just finished outgoing call
        PhoneFlag = 5
        Return
    End If       
    
    
    'Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber & "; PhoneFlag = " & PhoneFlag)
End Sub
 

moster67

Expert
Licensed User
I haven't tried the app but I believe it is possible the app is probably using some kind of third-party services which provides this kind of services accessible through rest-api.

Also, it is not unheard of device manufacturers, such as Samsung and others, that opens "backdoors" against a fee. Read that TeamViewer had made a deal which let their software remotely control Samsung android devices.
 
Last edited:
Top