Apps 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 putting the cpu to sleep at night, wake it up in the morning, collect and image, then go back to sleep in-between image collections (15 - 20 mins). The code i have used so far is based on the processing IDE with some android based java as well where necessary.

I have tried using wake-locks which didn't seem to work and have had a look at the AlarmManager class which might be the way to go but my programming skills aren't great. The AlarmManager class had 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 the next day(s) which adds another layer of complexity.

Any advice on this and/or example code to get me started would be much appreciated.