Sorry, i forgot that i can pass any intent to the alarm, please ignore my question :)
On Aug 11, 11:05 am, Teo <[email protected]> wrote: > I was also considering a service for my app, but reading this thread i > have second thoughts... Basically, all i want is a function to be > called at a preset time (every day). What's the recommended way of > doing this without a service? > > Thanks, > Teo > > On Aug 4, 2:09 am, Mark Murphy <[email protected]> wrote: > > > > > R Ravichandran wrote: > > > Thanks Mark. Actually the code I posted missed out the 'onStart' method > > > details that I actually tried. Here is the actual 'onStart' method of > > > the MyService class I used where I create the thread and starting it. > > > > @Override > > > public void onStart(Intent intent, int startId) { > > > System.out.println ("MyService ))))))))))))))))))))))))))"); > > > super.onStart(intent, startId); > > > Thread t = new Thread(this); > > > t.start(); > > > } > > > > I modified the run method I put some System.out. statement inside a > > > while(true) loop. The idea was to keep this service running as long as > > > the device is on. But it looks like the system is sending a SIG 9 to > > > kill the process (process id 697) for the 'service'. Here is the logcat > > > lines that I see. > > > > D/installd( 557): DexInv: --- BEGIN '/data/app/vmdl51510.tmp' --- > > > I/System.out( 697): =====>: inside the run method....Count = 49 > > > I/System.out( 697): =====>: inside the run method....Count = 50 > > > D/dalvikvm( 722): DexOpt: load 41ms, verify 52ms, opt 1ms > > > D/installd( 557): DexInv: --- END '/data/app/vmdl51510.tmp' (success) --- > > > D/PackageManager( 583): Services: com.bn.InStoreWifiConnectivityManager > > > D/PackageManager( 583): Receivers: com.bn.InStoreWiFiServiceInitiator > > > I/System.out( 697): =====>: inside the run method....Count = 51 > > > I/installd( 557): move > > > /data/dalvik-cache/d...@a...@[email protected] -> > > > /data/dalvik-cache/d...@[email protected][email protected] > > > D/PackageManager( 583): New package installed in /data/app/com.bn.apk > > > I/System.out( 697): =====>: inside the run method....Count = 52 > > > D/AndroidRuntime( 708): Shutting down VM > > > D/dalvikvm( 708): DestroyJavaVM waiting for non-daemon threads to exit > > > D/dalvikvm( 708): DestroyJavaVM shutting VM down > > > D/dalvikvm( 708): HeapWorker thread shutting down > > > D/dalvikvm( 708): HeapWorker thread has shut down > > > D/jdwp ( 708): JDWP shutting down net... > > > D/dalvikvm( 708): VM cleaning up > > > D/dalvikvm( 708): LinearAlloc 0x0 used 627404 of 4194304 (14%) > > > D/ActivityManager( 583): Uninstalling process com.bn <http://com.bn> > > > I/System.out( 697): =====>: inside the run method....Count = 53 > > > D/ActivityManager( 583): Force removing process ProcessRecord{436ea918 > > > 697:com.bn/10020 <http://com.bn/10020>} (com.bn/10020 > > > <http://com.bn/10020>) > > > W/ActivityManager( 583): Scheduling restart of crashed service > > > com.mypackage/.MyService in 5000ms > > > I/Process ( 583): Sending signal. PID: 697 SIG: 9 > > > D/ActivityManager( 583): Received spurious death notification for > > > thread android.os.binderpr...@436c0898 > > > E/ActivityThread( 583): Failed to find provider info for > > > android.server.checkin > > > W/Checkin ( 583): Can't log event SYSTEM_SERVICE_LOOPING: > > > java.lang.IllegalArgumentException: Unknown URL > > > content://android.server.checkin/events > > > > Looks the process Id 583 is the one that sends SIG 9. Any idea why this > > > is happening? > > > Possibly, it's because your service crashed: > > > > W/ActivityManager( 583): Scheduling restart of crashed service > > > com.mypackage/.MyService in 5000ms > > > Usually, logcat will show a stack trace associated with service crashes. > > > Bear in mind, though, that your process will be shut down for other > > reasons as well, such as memory reclamation. Keeping a service running > > all the time is an Android "code smell" -- while it is possible, and > > there are occasions when it is the right design, it feels like the vast > > majority of people try it when they don't need it. > > > Consider using an AlarmManager to start your service on a periodic > > basis, and have the service stopSelf() when the background thread is > > done performing that cycle's worth of work. This will be more reliable > > and, for reasonably long alarm periods, more efficient. > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://twitter.com/commonsguy > > > _Beginning Android_ from Apress Now Available! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

