Android: advice on method to wake up CPU from sleep, carry out a task then go back to sleep
-
HI, i have created a time lapse camera app that collects images during daylight hours and uploads those images to an FTP server. I now need to add a method to prolong battery life by waking up the cpu at a specific time, collect an image, then go back to sleep between image collections (15 - 20 mins) then stay asleep at night, this is repeated on a daily basis. The AlarmManager class might be the way to go but my programming skills aren't great. This class has an example that (i think) could wake the cpu at a given time then use the setRepeating method to wake up the device every x minutes after that. Is this correct? However i need it to stop doing that at night and repeat each day, is this possible? Any advice on this and/or example code to get me started would be much appreciated. Cheers.
-
HI, i have created a time lapse camera app that collects images during daylight hours and uploads those images to an FTP server. I now need to add a method to prolong battery life by waking up the cpu at a specific time, collect an image, then go back to sleep between image collections (15 - 20 mins) then stay asleep at night, this is repeated on a daily basis. The AlarmManager class might be the way to go but my programming skills aren't great. This class has an example that (i think) could wake the cpu at a given time then use the setRepeating method to wake up the device every x minutes after that. Is this correct? However i need it to stop doing that at night and repeat each day, is this possible? Any advice on this and/or example code to get me started would be much appreciated. Cheers.
Caveat - I know nothing about mobile development but it seems to me that putting the cpu to sleep and then asking it to run the alarm manager (while asleep) seems to be a disconnect somewhere!
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
Caveat - I know nothing about mobile development but it seems to me that putting the cpu to sleep and then asking it to run the alarm manager (while asleep) seems to be a disconnect somewhere!
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
Not necessarily. Many (probably almost all) devices have low power sleep modes that can be woken from by real time clock interrupts (and other interrupts, like a pushbutton). So setting a time-of-day alarm and going to sleep is a very effective strategy for minimising power consumption.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Not necessarily. Many (probably almost all) devices have low power sleep modes that can be woken from by real time clock interrupts (and other interrupts, like a pushbutton). So setting a time-of-day alarm and going to sleep is a very effective strategy for minimising power consumption.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
Hence the caveat - ty
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP