Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / Music Resumes on Resume

Author
Message
PaulTR
6
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 9th Dec 2012 03:15
I'm having some trouble finding a way around this, and I'm pretty sure it's an AppGameKit bug, but if anyone knows a solid fix that'd be awesome.

When my game comes back from the home screen, GetResumed() is true, but if I had music paused before leaving the game, it begins playing again.
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Dec 2012 04:15
You need to check stuff when you see GetResumed() as true.

The basic Android process is to start things back up just the way they were when the app was sent to the background.

How sure are you that the music was actually paused before the app goes to the background?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
PaulTR
6
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 9th Dec 2012 20:38
Positive it was paused. I have a music pause button in my menu that I would activate and stop the music, then hit the home button, return to the app and the music would be playing.
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th Dec 2012 15:20
You could try having a flag that is set when the music is supposed to be playing, or is paused, depends on your code. And then check that value in the code you execute after checking GetResumed() and start/stop music as appropriate.

Have you seen this behavior on more than one Android device?

Are you running your app directly on the device or through the Player? This might make a big difference.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
PaulTR
6
Years of Service
User Offline
Joined: 25th Oct 2012
Location: Fresno, CA
Posted: 11th Dec 2012 00:23
Yeah I've seen it on a Nexus 7, HTC Incredible 2 and a Samsung Galaxy somethingarather. I'll play around with flags. I tried but it wasn't catching all of the time, so I'll see what I can do.
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 11th Dec 2012 00:47
Are all the devices the same Android OS version?

Were you using the Player?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Daddy
10
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 15th Dec 2012 19:15
Hi Guys

I am having terrible trouble with my Game on Android when the home key is pressed. Somehow when it goes to the back ground and is then resumed I just get a blank screen.

It may be loosing the glContext but I am not sure. Currently Jim Hawkins is looking at my entire project but to date no coding issues found from my end!

I know little about Java\Android so am quite lost!

Constantly seeking!
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th Dec 2012 17:21
The Daddy, do you use the GetResumed() command to check for coming back from the background?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Dec 2012 22:48
No, he didn't. I can't find a single instance of this call in any AppGameKit example. We've discussed this in the Google report system.

What's for sure is that the Home key black screen is death, or close to death, for many apps. It needs to be seriously investigated, as I have requested.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Dec 2012 03:43
I have no trouble with the Home key in my app, on any device. But, then I do check GetResumed() at the start of every sync loop. And I know what I need to do when it returns true. As discussed in both of the google issues that were recently raised.

I actually checked all of the sample programs that come with AGK. None of them check GetResumed(). They are all geared towards Windows.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Jogimus
6
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 18th Dec 2012 08:15
(Tier1) I'm confused about this pause/resume thing.. if we don't get "OnPause" or "OnStop" signal then how we could handle "OnResume"... Normal android SDK or some other android developing environments offer us to proper ways to handle these situation (or actually we _must_ handle these situations..) so if all we get with AppGameKit is GetResumed() how we could know really from where to resume and what things to restore or reset??


I'm not saying that GetResumed() is useless, like Ancient Lady wrote somewhere, at least we can use that to change game to pause state so game don't just continue to run instantly after resuming from background.

But there is some odd things going on with pause/resume thing, like when using Tier1, AppGameKit is busy looping while in background (yes, little workaround is available but there should be no looping at all while in background..)
JimHawkins
10
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 18th Dec 2012 14:56
I have yet to find a single instance of GetResumed() actually firing on my device!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Dec 2012 16:54
I have GetResumed() working fine in my app and when it returns one and my app is in game play mode, the commands to pause the game are executed and work fine.

GetResumed() returns a one when you return from the background and you have to check it as the first thing in your execution loop.

AGK does not provide and triggered events because it handles all those types of things (key presses, touches, tilts, etc.) except for being sent to the background and returned.

In Tier 1 it theoretically would know all the variables and values and such because it interprets the data initially.

But in Tier 2, there is no way whatsoever for the AppGameKit engine to know what your variables are and how the logic in your app behaves. So it is up to the programmer to catch the event and handle it.

Which Tier the app was made in makes no difference on an Android. It just has an app that loads up.

I just ran a test, using the Player, counting the times GetResumed() returned one and keeping track of time spent rendering each frame (GetFrameTime()). The app displayed both values. Every time it was sent to the background and brought back, the counter incremented. And the frame time stopped updating while in the background.

Then I did the same with an app that has a bunch of stuff displayed and physics reactions. And the results were the same.

I tried using Message to display a message, and it does, but it is this small thing at the bottom of the screen. Hard to see and it disappears all by itself.

I have to reinstall my Eclipse/Android setup and then I'll post a Tier 1 and a Tier 2 apk that shows using the GetResumed() command.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
DVader
15
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 25th Dec 2012 15:37
I have had similar problems with a black screen. I also have had the app running itself over and over also. So you hit home, then hit the icon for your game. Instead of resuming, it simply loaded up again. Quitting the game ended up with the game exiting and re running as many times as you had exited using home. I use 1076 tier 1 so it's not a brand new thing. Clicking and advert or browser function and then hitting back to return to the game works fine though.

Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Jan 2013 16:09
There are apparently, on some Android devices (or maybe in the Android project settings), a setting that instructs your app to quit/restart if sent to the background. I haven't explored this and have not had the problem on my two test Android devices.

Are you using the GetResumed() command as about the first one in the main loop to see if you have returned from the background? It returns one when the home key was used to send your app to the background and then you use the app icon to start up (if it doesn't automagically exit).

I have been using that command in both Tier 1 and Tier 2 since early 107 and it has always worked in Android. (And now works in v1085 for iOS).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2019-08-26 08:11:38
Your offset time is: 2019-08-26 08:11:38