ionic framework - Cordova verify app is asleep when not active -


i'm having test users app taking battery life on android devices. i'm testing on tablet (nexus 7) , in settings > app info > permissions see prevent tablet sleeping.

so mean app is keeping device sleeping or can?

regardless need find out how make sure app not doing background processing. how can test this?

note: i'm using navigator.geolocation.watchposition , i'm concerned it's still running in background, taking more needed resources.

most issue navigator.geolocation.watchposition.

you want make use of device events handle stopping , starting when app paused , resumed.

here quick sudo example:

define global watcher var watcher;

add listeners pause , resume:

document.addeventlistener("pause", onpause, false); document.addeventlistener("resume", onresume, false); 

when start watcher assign global:

watcher = navigator.geolocation.watchposition(onsuccess, onerror, options); 

create onpause , clear watcher:

function onpause() {     navigator.geolocation.clearwatch(watcher); } 

if want start again when app resumed, create onresume , start again:

function onresume() {     watcher = navigator.geolocation.watchposition(onsuccess, onerror, options); } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -