Android Question Phone call without dialer?

W. Graf

Member
Licensed User
Longtime User
Hi everybody!

My company needs an address book, which can't be edited by an user. It's managed from "outside" and the user only should have "read-only" rights.
Because the phone's addressbook (contacts) can't be limited in this way, I decided to write an app in B4A, which reads the builtin phonebook and displays all the contacts. A MDM-system disables the icon to open the builtin-contacts of the phone.
The user can touch one of the contacts, which my app shows and then, my app will call this contact. I'm using the Phone-library to make the call, like this one:

B4X:
Dim p As PhoneCalls
StartActivity(p.Call("12345678"))

Everything works fine, but my Samsung phone opens the builtin dialer, when I click the contact. The problem is, that this dialer offers a button named "View contact" (I only have a German phone, so I THINK, that an english Android would show "View contact"...). If the user clicks on it, then the contact will be opened an the user is able to edit it. So my App makes no sense anymore...

Do you know, if there is a possibility in B4A, to call the number without showing the default dialer of my phone?

Thank you in advance!
Nice greetings,
Wolfgang
 

W. Graf

Member
Licensed User
Longtime User
Thank you Erel for your quick reply!

Unfortunately it doesn't work. It's still coming the default dialer of my phone.

The B4A-Manifest-Editor contains the following lines (I have added a few additional lines, which I have found in the different communities):
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddActivityText(ActDialer,
<intent-filter>
        <action android:name="android.intent.action.CALL_BUTTON" />
        <action android:name="android.intent.action.CALL_PRIVILEGED" />
        <action android:name="android.intent.action.VIEW" />
        <action android:name="android.intent.action.DIAL" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="tel" />
</intent-filter>)
AddPermission("android.permission.CALL_PHONE")
AddPermission("android.permission.READ_CONTACTS")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

The activity ActDialer should be shown, but it doesn't appear.


To call somebody, I'm using these lines:
B4X:
Dim Dial As Intent
Dial.Initialize(Dial.ACTION_CALL, "tel:12345678")
StartActivity(Dial)

I also tried this one:
B4X:
Dim p As PhoneCalls
StartActivity(p.Call("12345678"))

Can you tell me, what I'm doing wrong?

Thank you again!!!
Nice greetings,
Wolfgang
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
I forgot to say:
My phone doesn't ask me, which app I want to use to dial a number. I know, which window you mean, but it doesn't appear - so I can't choose my App as dialer-app.
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
Thank you Erel!
That was the missing detail, why it didn't work up to now. Adding this action in the Manifest shows me the window to choose the dialer app. :)
But: now I can't make a phone call.

On my Dialer-activity, I placed a Button, which should do the call.

I tried in Button_Click:
B4X:
Dim p As PhoneCalls
p.Call("12345678")
--> nothing happens.


Then I tried:
B4X:
Dim I As Intent
I.Initialize(I.ACTION_CALL, "tel:12345678")
StartActivity(I)
--> my Dialer-Activity starts itself again and again: of course, because I defined this behaviour with my previous steps.


I also "played" with the Manifest-entries (removing and adding lines), but nothing helped.
Any further ideas?
I'm sorry, I don't want, that you make my mental work or my job, but I have no idea what I can try anymore (-> I'm not very similar with Intents and the "deep system components of the Android core ....).
Maybe it is not possible to replace the dialer-UI in such a way?

Thank you!
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
I've just tried with a new activity.
So I have Activity A, which should starting the call:
B4X:
Dim p As PhoneCalls
StartActivity(p.Call("12345678"))

And Activity B was defined as Dialer-UI (via Manifest-File).

If I want to make a call from Activity A, then Activity B starts (-> perfect!), but nothing else. The phone is not dialing.

So it seems to me, that it is not possible. I'm afraid to cancel the project...
Nevertheless I want to thank you for your time and your advices!!
 
Upvote 0
Top