I've placed the stub of some new logic into a Service that will rely on AlarmManager to periodically goose the service. I've been using "adb shell dumpsys alarm" and logcat to trace it, and it seems that I have been able to set the alarm and I see evidence that the alarm is tripped. But I don't see evidence that the event is delivered to my BroadcastReceiver. I suspect that I am not properly registering the receiver or I am misusing Context. I would appreciate an extra set of experienced eyes.
In the startup logic of my service is the code which instantiates an inner class (Alarm) which serves as the BroadcastReceiver and also provides the utility function to set the alarm... if (!pulse.isAlive()) { pulse.start(); alarm = new Alarm(); String acs = Alarm.class.toString(); IntentFilter ifilt = new IntentFilter(acs); registerReceiver(alarm,ifilt); alarm.setAlarm((Coordinator)this,15000); // in 15 secs Log.d(TAG,"ALARM SH BE SET -----------------*_*_*_*_* - "+acs); } The logcat confirms execution (the Service class is called Coordinator)... D/CoordMT ( 322): ALARM SH BE SET -----------------*_*_*_*_* - class net.from.apprise.Coordinator$Alarm Correspondingly, the dumpsys alarm output shows creation of the alarm after invocation: Realtime wakeup (now=1337434262327): RTC_WAKEUP #0: Alarm{4503cc48 type 0 net.from.apprise} type=0 when=1337434275855 repeatInterval=0 count=0 operation=PendingIntent{45049198: PendingIntentRecord{45000eb0 net.from.apprise broadcastIntent}} and after the elapsed period, it also shows the alarm history count incremented as expected (from 2 to 3 in this case)... Alarm Stats: android ... stuff omitted ... net.from.apprise 52ms running, 3 wakeups 3 alarms: flg=0x4 cmp=net.from.apprise/.Coordinator$Alarm But I don't see expected trace meesage from the BroadcastReceiver... public class Alarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG,"BING1 ****** ------------------------- ************"); PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"YOUR TAG"); wl.acquire(); Log.d(TAG,"BING2 ****** ------------------------- ************"); wl.release(); } public void setAlarm(Context context,long msFuture) { AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context,Alarm.class); PendingIntent pi = PendingIntent.getBroadcast(context,0,i,0); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+msFuture,pi); } } The Service containing the Alarm object is definitely running when the alarm is tripped, and I have no reason to believe that the Alarm object has been freed. I would appreciate some tips for diagnose, or if there is an obvious error, a blatant clue! Thanks for your attention. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en