Android Question Phone call without dialer

Colin Evans

Active Member
Licensed User
Longtime User
Just trying to use an app that I did sometime ago and now when I try and make a telephone call it returns a error

This works but brings up the dialler
B4X:
Sub button1_click
    rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
    Wait For Activity_PermissionResult(permission As String,result As Boolean)
    If result Then
        Dim result2 As Int
        result2 = Msgbox2("Dog In The Lane", "Do you wish to dial the number ?", "Yes", "", "No", Null)
        If result2 = DialogResponse.Positive Then
            Dim i As Intent
            i.Initialize(i.ACTION_VIEW, "tel:01939210000") 'dummy number but I use the xorrect number in the app
            StartActivity(i)
            'Dim p As PhoneCalls
            'StartActivity(p.Call("01939210000")) 'dummy number
        End If
    End If
End Sub

It works now I've changed the code to use Dim i as intent but brings up the dialler interface, it now doesn't work if I rem out those lines and un-rem the Dim p as PhoneCalls ans StartActivity(p.call( etc

As something changed that you can't use PhoneCalls

This doesn't work but used to
B4X:
Sub button1_click
    rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
    Wait For Activity_PermissionResult(permission As String,result As Boolean)
    If result Then
        Dim result2 As Int
        result2 = Msgbox2("Dog In The Lane", "Do you wish to dial the number ?", "Yes", "", "No", Null)
        If result2 = DialogResponse.Positive Then
            'Dim i As Intent
            'i.Initialize(i.ACTION_VIEW, "tel:01939210000") 'dummy number but I use the xorrect number in the app
            'StartActivity(i)
            Dim p As PhoneCalls
            StartActivity(p.Call("01939210000")) 'dummy number
        End If
    End If
End Sub

and returns the error
--------- beginning of crash
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main$ResumableSub_button1_clickresume (java line: 557)
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxx flg=0x20000 cmp=com.android.server.telecom/.components.UserCallActivity } from ProcessRecord{1cc3d23 1656:ditl.thedoginthelane/u0a196} (pid=1656, uid=10196) with revoked permission android.permission.CALL_PHONE
at android.os.Parcel.createException(Parcel.java:1950)
at android.os.Parcel.readException(Parcel.java:1918)
at android.os.Parcel.readException(Parcel.java:1868)
at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:3714)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1669)
at android.app.Activity.startActivityForResult(Activity.java:4586)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
at android.app.Activity.startActivityForResult(Activity.java:4544)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
at android.app.Activity.startActivity(Activity.java:4905)
at android.app.Activity.startActivity(Activity.java:4873)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:857)
at ditl.thedoginthelane.main$ResumableSub_button1_click.resume(main.java:557)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6702)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1786)
at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:720)
at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:547)
at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1118)
at com.android.server.am.ActivityStarter.execute(ActivityStarter.java:488)[/code]
 

DonManfred

Expert
Licensed User
Longtime User

1.


CALL_PHONE is a dangerous permission

2.
As you need this permission you also need to request this permission with runtimepermissions.

See https://www.b4x.com/android/forum/threads/android-jar-targetsdkversion-minsdkversion.87610/

Requesting rp.PERMISSION_READ_PHONE_STATE is the wrong permission. You need it TOO maybe.

At the end i fear that it will only work if your app is the devices default dialer app
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…