Software Archive
Read-only legacy content
17061 Discussions

Android tablet, resume and pause ? Help

Leo_N_Ng_
New Contributor I
848 Views

The function resume and pause functions don't work properly on my tablet Dragon Touch Y88. This device can't resume my game ,everywhen I pause the game, went to the menu screen of the tablet, then went back to the game, the game always restart. It work fine on my other devices ( Samsung S3, HTC one, ... ). Other games can pause and resume, but my game is using Construct 2 with Intel XDK , these functions didn't work on this tablet. Please help to fix this ! Thank you.

Code:
 

document.addEventListener("pause", function() {
     cr_setSuspended(true);
}, false);
			
document.addEventListener("resume", function() {
     cr_setSuspended(false);
}, false);

 

0 Kudos
6 Replies
PaulF_IntelCorp
Employee
848 Views

My suspicion is that the device has low memory and the Android OS is closing the app after pause (or the "Don't keep activities" option might be turned on in the "Developer Options" of the problem device.

If the app is closed it will result in a restart.

Can you confirm that you are or are not getting the pause and resume functions?

0 Kudos
Leo_N_Ng_
New Contributor I
848 Views

Thank your help , Paul ^ ^.
If i pressed the button to minimize ( pause ) on the menu navigator ( bottom black bar on Android tablet with some buttons ), then I get back to the game right the way, the game can resume at that moment. If i paused the game then go to the main screen of this tablet and work on other apps or do something outside my game, then I got back to the game, the game is closed and restarted.

P/S : Other games on this tablet work perfect without problem of this issue.

0 Kudos
PaulF_IntelCorp
Employee
848 Views

Can you confirm whether or not you are seeing the pause and resume events?

0 Kudos
Leo_N_Ng_
New Contributor I
848 Views

Sorry Paul, i don't get you >.< Where can I see the pause and resume events ? In my code or somewhere ?

0 Kudos
PaulF_IntelCorp
Employee
848 Views

Hello Leo. According to the code snippet you provided in a prior post you've got a function that is being called whenever you receive either a pause or resume event. You could add some console.log() messages in there to see if the events are happening. You'll have to be watching the console to see these messages (and I'm assuming the console will still be alive when these happen, so this might get tricky). But the simplest thing to do might be something like this:

document.addEventListener("pause", function() {
	     console.log("pause begin"); cr_setSuspended(true); console.log("pause end");
	}, false);
	             
	document.addEventListener("resume", function() {
	     console.log("resume begin"); cr_setSuspended(false); console.log("resume end");
	}, false);

And then set the "debuggable" equal to "true" in the additions.xml file, similar to this file: https://github.com/xmnboy/hello-cordova/blob/master/intelxdk.config.additions.xml.

Once you have the above, build the app (using Crosswalk) and install it on your test device. Use the USB and remote CDT to monitor the console from your app. See this article for some help: https://software.intel.com/en-us/xdk/docs/intel-xdk-debug-and-test-overview#RemoteChromeDevTools

0 Kudos
Leo_N_Ng_
New Contributor I
848 Views

@Paul Fischer (Intel) Thank you so much

0 Kudos
Reply