Android Question Receive a call after exiting Kiosk (admin) mode

Andrew Webb

Member
Licensed User
Longtime User
Hi all

I have an app based on the Kiosk mode from here:
https://www.b4x.com/android/forum/threads/device-owner-tasklock-kiosk-apps-2017.81765/

I want the device to also receive phone calls. I didn't realize that kiosk mode would prevent the phone app
from appearing.

As a workaround, I'm using this code to detect when the phone rings:
B4X:
'call processing
    If StartingIntent.Action = "android.intent.action.PHONE_STATE" Then
    Select StartingIntent.GetExtra("state")
          
        'onhook - call ended or phone idle
        Case "IDLE"
            Log("Call ended")
                  
            'outgoing call processing
        Case "OFFHOOK"
          
            'incoming call processing
        Case "RINGING"
            Log("CallerID="&StartingIntent.GetExtra("incoming_number"))
                CallSubDelayed(Main,"btnUnlock_Click")

The call to 'btnUnlock_Click' takes the app out of kiosk mode while the call is ringing. My problem is that the call does not appear on the screen, its in the background. This app will be the default Launcher on the device so I really need to call to just appear on top.

I can't work out how to get the 'active phone call' activity to come into focus though so the user can answer it.

Any ideas or alternatives greatly appreciated!

Andy
 

Andrew Webb

Member
Licensed User
Longtime User
Hi Erel, yes, the admin mode is released and pressing the back button and then the phone icon reveals the incoming call.

I have added the following code to the service to try to bring the incoming call to the front but it brings the phonebook app to the front instead:

B4X:
'Service module

 'incoming call processing
        Case "RINGING"
            Log("CallerID="&StartingIntent.GetExtra("incoming_number"))
                CallSubDelayed(Main,"btnUnlock_Click")
                Sleep(3000)
                
                Dim Intent1 As Intent
                Intent1.Initialize(Intent1.ACTION_MAIN,  "")
                Intent1.SetComponent("com.android.providers.telephony")
                StartActivity(Intent1)

I tried a couple of the installed packages that looked like they might handle calls but none brought up the incoming call. Is there a URI reference maybe or a different ACTION?
(Or something else lol??)

Cheers
 
Upvote 0

Andrew Webb

Member
Licensed User
Longtime User
Thanks Erel, it goes to the phonebook too. When there is no incoming call, pressing the phone icon goes to the same 'phonebook' page. Does that mean it's the right package but there is a different activity in that package?

(The first time I ran my original code I got a 'choice' dialog - I pressed the 'Always' option. Could it be that choice is still cached somewhere and affecting the things I'm trying now? - Even though the package is different?)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Andrew Webb

Member
Licensed User
Longtime User
I've spent some time analysing the available activities in that package using the tool you suggested above. I also tried the PhoneCalls.Call package. There were a few activities to try but none of them go to the incoming call - they all just went to the phonebook page. I also tried the 'Youtube' example to rule out anything odd going on with it; It went straight to youtube.

I'm thinking of a different strategy for my app. o_O

Thanks for the suggestions Erel - I did learn a bit about the contents of the APK's lol!
 
Upvote 0
Top