AIR to Android - Background App keeps playing sound

One of the differences I noticed with AIR on iOS and AIR on Android devices is that when you press the "back" or "home" button on iOS, it automatically pauses all sounds from the app. On the Android you have to do something separately code-wise to get it to work.

The fine folks over at Cartoon Smart Blog did a post about how they handled it. Here is the code here in the most simplified way.
if (Capabilities.cpuArchitecture=="ARM")
	NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
	NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);

function handleActivate(event:Event):void
	NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

        // whatever functions to run once the app reopens from background state


 function handleDeactivate(event:Event):void

	// whatever functions to run when user puts app in background
Related Link: Cartoon Smart Blog - what To Do When Your AIR to Android App Closes

Special Thanks: SyntaxHighlighter (so cool!)