Android Question Start PhoneCall from background service

Nerdworld

Member
Licensed User
Longtime User
Hello folks,

I tried adding the FLAG_ACTIVITY_NEW_TASK and FLAG_FROM_BACKGROUND flags to the Phone call intent, as mentioned here:

B4X:
Dim P As PhoneCalls
Dim In As Intent = P.Call(Param)
In.Flags = Bit.Or(268435456, 4) 'FLAG_ACTIVITY_NEW_TASK + FLAG_FROM_BACKGROUND
StartActivity(In)

Dim In As Intent
In.Initialize2("tel:" & Param, Bit.Or(268435456, 4))
In.Action = In.ACTION_CALL
In.Flags = Bit.Or(268435456, 4) 'FLAG_ACTIVITY_NEW_TASK + FLAG_FROM_BACKGROUND
StartActivity(In)

It's not working and i'm getting no error message or hint. Code works fine when called while the Main activity is running.
Any ideas?
 

Nerdworld

Member
Licensed User
Longtime User
this can help or guide:

I don't really see what this topic has to do with my question.
Receiving intents and broadcasts as well as receiving SMS in my background service already works fine.
 
Upvote 0

Nerdworld

Member
Licensed User
Longtime User
Two more threads on this : https://stackoverflow.com/questions/17676221/intent-action-call-in-background
https://stackoverflow.com/questions...-and-come-back-to-my-activity-when-the-call-i

You may not be able to do exactly that you want, but there seems to be a possible alternative.

Both of them have slightly different problems - i don't want to hide the dialer (and let the call run in background), i just want to start a call while my own application just runs as a background service - for example when the screen is off or while I'm doing something else.

The problem is, that you can't call StartActivity from an Service module - and CallSubDelayed just waits until you reopen the app.
 
Upvote 0

Nerdworld

Member
Licensed User
Longtime User
Adding the permission allowed me to change this option in the App settings.

At least on my HUAWEI Mate 20 Pro with Android 10.1 this seems to be enough.
 

Attachments

  • Screenshot_20201221_115513.jpg
    Screenshot_20201221_115513.jpg
    228.3 KB · Views: 260
Upvote 0
Top