Tuesday, June 7, 2011

Re: [android-developers] Alarm Manager...spoke to soon

You are not setting an alarm. You are calling startService().

On Tue, Jun 7, 2011 at 4:48 PM, Simon Platten
<simonaplatten@googlemail.com> wrote:
> Hi,
>
> Thank you Mark again for the BOOT_COMPLETED onReceive sample...I have
> implemented my version of the code and can see that it does call the
> onReceive method on boot, I've put in a Toast message just to see that its
> being called.
>
> However, the logic I've added to kick start my application by installing a
> new alarm in the alarm manager as shown in the example doesn't work.  I
> don't get any exception raised, I've put a Toast message before and after
> the calls to the alarm manager setting and both are displayed, but the alarm
> itself doesn't fire:
>
> public class onBootReceiver extends BroadcastReceiver {
>     @Override
>     public void onReceive(Context context, Intent intent) {
> // Get application settings
>         clsWallpaper.wpSettings settings = clsWallpaper.getSettings( context
> );
>
>         if ( settings == null ) {
>             Toast.makeText(context, "Cannot get Wall-paper\nsettings",
> Toast.LENGTH_SHORT).show();
>             return;
>         }
>         Toast.makeText(context, "Wall-paper interval:\n" + Long.toString(
> settings.m_lngInterval ), Toast.LENGTH_SHORT).show();
>         clsWallpaper.startService(context,
>                                   settings.m_intNextImg,
>                                   settings.m_intScaling,
>                                   settings.m_intRotation,
>                                   settings.m_lngInterval);
>         Toast.makeText(context, "Wall-paper onBootReceiver",
> Toast.LENGTH_SHORT).show();
>     }
> }
>
> Thank you,
> Simon
>
> --
> 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+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.4 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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment