-1

The question is very strange:

i have done an app that set an Alarm Manager that lunch a service (it does some operation and at the end stopself()) every 5 minutes. For at least 6 month or more (plugged).

This because i have tranformed my phone in a webcam (IP wireless for panorama wiev), so the service started each 5 minutes take a photo and send it by wifi. So there isn't any user interaction and the phone is away from user control. My app works fine with very fine result, but after 5-6 days working something happens and the app crashes. I think that is the Andorid OS that close the app, but i can't understand how it can cancel di alarm manager schedule operation..

The app is installed on a Samsung Galaxy ACE, i'm thinking to root the phone and cancel all other app on the phone, so that may not be problem.

There is a better way to be sure that the app will run for 6 month or more?

Would be better make a custom rom for this pourpose?

Sorry for my english..

Lork
  • 889
  • 3
  • 12
  • 24
  • "Something crashed" does not tell anything. Do you have logcat output at hand? Are you using service or broadcast recveiver ( this would be immune to crashes) – Konstantin Pribluda Dec 23 '11 at 09:42
  • Frome the logcat inside the phone (is not connected to pc) i can't find anything worng. Seem that android kill the app without any reason (or need memory?). I'm using an Alarm Manager that lunch a service (that start and stop in few seconds) each 5 minutes. For therest of the time my app is closed. I can't explain better! Thanx! – Lork Dec 23 '11 at 09:48

1 Answers1

0

Android can (and actually does) kill applications for its internal reasons. So if you need something resurrected, best way is to use broadcast receiver, and schedule repeating alarm with alarm manager (you have choices, whether it will wake up the phone or not, or whether this shall be at exact times or there is amouint if slip allowed). I also discovered that scheduled alarms not always survive phone reboot - but you can overcome it by registering BOTT_COMPLETE listener, which will reschedule your briadcasts on reboot.

I'm developing application which does this:

https://github.com/ko5tik/camerawatch

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
  • Thanx for answer but i don't understand "So if you need something resurrected, best way is to use broadcast receiver" i'm currently using alarm manager (i said it) that start a service and all work ok. The problem is that after man many hours of working (6 days) android kill the app AND the alarm manager! The wake lock doesn't matter now (i use it to perform the entire service execution but it is dropped at the end because i don't need it, there is alarma manager that restart the service). That's my current webcam: http://foicam.altervista.org/visualizzawebcam.php?codice=cd299bd9a07e2e51# – Lork Dec 23 '11 at 10:39
  • Please tell me if this maybe solve the problem: create the app without any user control (start automatically alarm manager at onCreate() and set it autorun on boot). Then make another app that with a service called by another alarm manger, reboot the phone each 6 hour and it will be autorun too. So that if the main app crashes, the other app help rebooting the entire phone, solving all problems. Is it true? thanx (of course need rooted phone but you have understand that this is not a problem..) – Lork Dec 23 '11 at 11:03
  • You do not need autorun - BOOT_COMPLETE broadcast also does the trick. just reboot it every 6 ( or whatever convenent ) hours. As you provide webcam, you can do it nightly ( when it's dark ) – Konstantin Pribluda Dec 23 '11 at 12:41
  • Thanx @Konstantin Pribluda have you got an example of "not need autorun - BOOT_COMPLETE broadcast also does the trick" ? I'cant find nothing... – Lork Dec 23 '11 at 13:10
  • Look at the github link I posted. This application has BOOT_COMPLETE interceptor – Konstantin Pribluda Dec 23 '11 at 13:27