Ok, I found the problem, hope this thread helps somebody else with the
same stupid errors:

My <receiver> was inside the <manifest> but outside the <application>
tags :-/

On 30 mar, 11:05, Juanjo <[email protected]> wrote:
> I have a code that sets a new repeating alarm (on production I'll use
> a inexactRepeating), but the BroadCastReceiver I've registered for
> handling it is not being called.
>
> Here is the code where I set the alarm:
>
> ////////////////////////////
> long newAlarmPeriod = 5000; // For debugging
>
> Intent alarmIntent = new Intent(this, GroupsCheckAlarmReceiver.class);
> PendingIntent sender = PendingIntent.getBroadcast(this,
> Constants.CHECK_ALARM_CODE,
>                                                   alarmIntent, 0);
>
> AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
> am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
>                 + newAlarmPeriod, newAlarmPeriod, sender);
>
> //////////////////////////////
>
> It seems to work and it triggers and alarm every five seconds, as seen
> in the output of "adb shell dumpsys alarm":
>
> /////////////////////////////////
> DUMP OF SERVICE alarm:
> Current Alarm Manager state:
>
>   Realtime wakeup (now=1269941046923):
>   RTC_WAKEUP #1: Alarm{43cbac58 type 0 android}
>     type=0 when=1269997200000 repeatInterval=0 count=0
>     operation=PendingIntent{43bb1738: PendingIntentRecord{43bb1248
> android broadcastIntent}}
>   RTC_WAKEUP #0: Alarm{43ce30e0 type 0 com.almarsoft.GroundhogReader}
>     type=0 when=1269941049555 repeatInterval=5000 count=1
>     operation=PendingIntent{43d990c8: PendingIntentRecord{43d49108
> com.almarsoft.GroundhogReader broadcastIntent}}
>   RTC #1: Alarm{43bfc250 type 1 android}
>     type=1 when=1269993600000 repeatInterval=0 count=0
>     operation=PendingIntent{43c5a618: PendingIntentRecord{43c4f048
> android broadcastIntent}}
>   RTC #0: Alarm{43d67dd8 type 1 android}
>     type=1 when=1269941100000 repeatInterval=0 count=0
>     operation=PendingIntent{43c4e0f0: PendingIntentRecord{43c4f6c8
> android broadcastIntent}}
>
>   Broadcast ref count: 0
>
>   Alarm Stats:
>   android
>     24390ms running, 0 wakeups
>     80 alarms: act=android.intent.action.TIME_TICK flg=0x40000004
>   com.almarsoft.GroundhogReader
>     26ms running, 2 wakeups
>     2 alarms: flg=0x4
> cmp=com.almarsoft.GroundhogReader/.GroupsCheckAlarmReceiver
>
> ///////////////////////////////////
>
> But for some reason my BroadCastReceiver is not being called when the
> alarm is triggered. I've declared it on the Manifest:
>
> //////////////////////////////
> <receiver android:name=".GroupsCheckAlarmReceiver" />
> /////////////////////////////////
>
> And this is the abbreviated code of the BroadCastReceiver:
>
> ///////////////////////////////////
> public class GroupsCheckAlarmReceiver extends BroadcastReceiver{
>   @Override
>   public void onReceive(Context context, Intent intent) {
>      Toast.makeText(context, "XXX Alarm worked.",
> Toast.LENGTH_LONG).show();
>      Log.d("XXX", "GroupsCheckAlarmReceiver.onReceive");
>   }
> /////////////////////////////////

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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to