Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Android: advice on method to wake up CPU from sleep, carry out a task then go back to sleep

Android: advice on method to wake up CPU from sleep, carry out a task then go back to sleep

Scheduled Pinned Locked Moved Android
androidsysadmintutorialquestion
4 Posts 3 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 15274082
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • M Member 15274082

      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.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • M Mycroft Holmes

        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

        P Offline
        P Offline
        Peter_in_2780
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • P Peter_in_2780

          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

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Hence the caveat - ty

          Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups