Page 1 of 1

Detect incoming calls on android

Posted: Tue Sep 03, 2019 7:21 pm
by amyren
Is there a way for Hollywood apps to be notified when there is an interuption, like an incoming call, or if the user accidently touches the home or menu button?
I want to detect this to be able to set my game into pause.

Edit. Will InactiveWindow work for android, even if it is in fullscreen?

Re: Detect incoming calls on android

Posted: Mon Sep 09, 2019 5:16 pm
by airsoftsoftwair
The InactiveWindow event handler is supported on Android but I don't know if it's going to trigger on incoming phone calls... it should definitely trigger when hiding the app.

Re: Detect incoming calls on android

Posted: Tue Sep 24, 2019 10:14 am
by amyren
airsoftsoftwair wrote: Mon Sep 09, 2019 5:16 pm The InactiveWindow event handler is supported on Android but I don't know if it's going to trigger on incoming phone calls... it should definitely trigger when hiding the app.
Unfortunately it does not seem to trigger on android for me.
I have this piece of code in my game, which does set the game on pause when I run it in windows and switch to another program.
But running it on android does not set pause mode if I activate another app.

Code: Select all

InstallEventHandler({InactiveWindow = p_HandlerFunc})

Function p_HandlerFunc(msg)
	Switch(msg.action)
		Case "InactiveWindow":
		paused = True
		DisplaySprite(22, 225, 175)
	EndSwitch
EndFunction

Re: Detect incoming calls on android

Posted: Fri Sep 27, 2019 11:35 pm
by airsoftsoftwair
Which Android version and how do you switch to another app?

Re: Detect incoming calls on android

Posted: Wed Oct 02, 2019 5:29 pm
by amyren
airsoftsoftwair wrote: Fri Sep 27, 2019 11:35 pm Which Android version and how do you switch to another app?
I have tested on android 9.0 (my main phone), 8.1.0(tablet), and 4.2.1(old phone)

The way I switch to other app is tested on all devices, by either pressing the home button, or use the menu button to show all running apps and select another app. The game continues to run, without going to pause mode.
Additionally I have tested on my phone to get an incoming call while playing the game, then by accepting the call the phone switch to the calling screen, and still the game continues to run in the background.

Re: Detect incoming calls on android

Posted: Wed Oct 02, 2019 5:54 pm
by amyren
Here is a small app for testing this with hollywood player on android.
I just realized that my example shown above was not a good example, since installeventhandler must be put after function in order to work.

Code: Select all

@DISPLAY {Title = "Test", Width = 640, Height = 480, Color = #BLUE}

Function p_HandlerFunc(msg)
	Switch(msg.action)
	Case "InactiveWindow":
		TextOut(10,10, "INACTIVITY DETECTED")
	Case "CloseWindow":
		sel = SystemRequest("Quit?", "Quit app?",  "Yes|Cancel")
		If sel = 1 Then End
		ResetTimer(2)
	EndSwitch
EndFunction

InstallEventHandler({InactiveWindow = p_HandlerFunc, CloseWindow = p_HandlerFunc})

Repeat 
	CheckEvent()
Forever

Re: Detect incoming calls on android

Posted: Tue Oct 15, 2019 3:49 pm
by airsoftsoftwair
Ok, this is not a bug. "InactiveWindow" and "ActiveWindow" are triggered when using multiple Hollywood displays and cycling through them. What you want is listening to "HideWindow" and "ShowWindow". Those will trigger when minimizing and deminimizing the app...

Re: Detect incoming calls on android

Posted: Tue Nov 26, 2019 6:12 pm
by amyren
Thank you. I just compiled a version using HideWindow, and it does trigger when the app is sent to the background. It will not trigger directly on incoming calls, since the hollywood app window still is active behind the popup call buttons. When the call is accepted, the app window will be hidden and HideWindow is triggered.