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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -