Reputation: 2225
I am developing a PhoneGap / JQMobile app that plays Audios on Android Phone from an Internet source. For this I am using HTML5 .
When a phone call comes in or a notification beeps for SMS etc., the Audio stops playing and doesn't resume afterwards. My understanding is that I should use addEventListner for "pause" and "resume" (and please correct me if I am wrong) to implement auto-restart functionality. However the respective callback functions for these events are not fired when a notification/call arrives or finishes.
Here is the eventlistner code and callback functions:
document.addEventListener('deviceready', deviceReady(), false);
function deviceReady() {
document.addEventListener("pause", AppPaused, false);
document.addEventListener("resume", AppResumed, false);
}
function AppPaused()
{
$(".message").text("Application Pause");
alert("app paused");
return;
}
function AppResumed()
{
$(".message").text("Application Resumed");
alert("app resumed");
return;
}
Can someone please help me resolve this issue.
Thanks & Regards
AR
Upvotes: 0
Views: 1358
Reputation: 3824
Use this:
$(document).ready(function() {
document.addEventListener("resume", AppResumed, false);
function AppResumed() {
// Handle the resume event
$(".message").text("Application Resumed");
alert("app resumed");
}
});
Edited:
phonegap.js must be added and cordova js removed in order for this to work!
Upvotes: 1