Bingo.  My fog enveloped the precise use of Intents, as you
undoubtedly inferred.  The alarm is being caught in the receiver now.
I thank you for your very direct, clear identification of the problem
and the equally clear solution,

Further to the broader scope of the application:

The application has been functioning properly.  One of its functions
is to periodically sleep for periods which are determined by multiple
factors such as detected activity level of peers or use by the local
user.  I want to allow the user to leave the Service running at all
times for the purpose of maintaining local data currency obtained from
peers via a server and alerting the user occasionally, who
periodically runs a companion Activity.  But when the sleep intervals
are large, it is obviously unwise to hold a WakeLock.  Thus I have
turned to AlarmManager - basically to goose the Service after it has
allowed the phone to shutdown for awhile.  That's what I'm
experimenting with.

The user has the option of shutting down the service completely or
leaving it running indefinitely.  When it is running, it shows an icon
in the notification bar.  I suppose I could rely on AlarmManager to
restart the Service after all pauses, but that raises more questions.
For one, would the notification icon remain?  Also, would it be
advantageous in the event that my Service is in a period of short
duration pauses such as 5 seconds?  From the opposite perspective, is
there any serious negative consequence to leaving a Service running
during phone sleep and simply goosing it with an alarm as I'm
proposing?

Thanks again.

On May 19, 10:35 am, Mark Murphy <mmur...@commonsware.com> wrote:
> On Sat, May 19, 2012 at 10:14 AM, Bill Michaelson
>
> <wmmichael...@gmail.com> wrote:
> > 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 primary point behind AlarmManager is to run code when nothing else
> of your code is running. Why are you using both AlarmManager *and*
> what appears to be a long-running service?
>
> Note that your BroadcastReceiver is being registered with an
> IntentFilter that uses an action string.
>
> > But I don't see expected trace meesage from the BroadcastReceiver...
>
> Because you are not broadcasting an Intent that will be picked up by
> that IntentFilter.
>
> >         Intent i = new Intent(context,Alarm.class);
>
> This broadcast does not use an action string. It uses a component.
> This would be a fine choice if your BroadcastReceiver were registered
> in the manifest, but yours is not.
>
> If you want to send a broadcast to an IntentFilter that uses an action
> string, your Intent that you are broadcasting must use the same action
> string (e.g., new Intent("this.is.my.action.string")), not a
> component.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.6
> Available!

-- 
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

Reply via email to