Broadcast receiver throws error after reboot when application was not opened before

I have a broadcast receiver, launching after reboot to set several alarms with the help of the alarm manager. The broadcast and the receiving after the reboot works perfectly, however the alarm being set in this broadcast throws an error when being fired.

E/AndroidRuntime(4330):     at mobileTechnology.geoCalendar.SetAlarm.checkReminder(
E/AndroidRuntime(4330):     at mobileTechnology.geoCalendar.SetAlarm.access$1(
E/AndroidRuntime(4330):     at mobileTechnology.geoCalendar.SetAlarm$1.gotLocation(
E/AndroidRuntime(4330):     at mobileTechnology.geoCalendar.CurrentLocation$2.onLocationChanged(

When I open the application after the reboot before the other alarms are fired, there will be no error. Do you have any idea, why the app is behaving that way? In the broadcast receiver I'm accessing a normal java class (no activity) to determine the current position by a callback. Is there a problem accessing this class when the application was not opened before?

EDIT: I guess I configured my manifest file the wrong way, as there is missing an Intent filter. Can anyone tell me what's the right way to do it?

<receiver android:name="SetAlarm"></receiver>


thank you, so here is some more code of my project:

During runtime a set up several alarms for events by using the alarm manager. The alarm is created by calling

new SetAlarm (Context context, Bundle bundle, Long time_how_far_in_advance_alarm_should_be_fired)

The bundle contains detailed information about the event (name, time ...) and the SetAlarm constuctor looks like the following:

AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, SetAlarm.class);
intent.putExtra("data", bundle);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, bundle.getInt("id"), intent,PendingIntent.FLAG_UPDATE_CURRENT);

Calendar cal = Calendar.getInstance();
*<set time for reminder>*
alarmMgr.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),

The receiver is in the same class as the broadcast and defined by

<receiver android:name="SetAlarm"></receiver>

Until this point everything works perfect as alarms are being fired when they should be and a notification will be displayed.

To reload the alarms after a reboot, there is another class ReloadAlarms, loading all Events out of a database and setting up the alarms again.

public void onReceive(Context context, Intent intent)

<receiver android:name="ReloadAlarms" >
        <intent-filter >
            <action android:name="android.intent.action.BOOT_COMPLETED" />

The alarms are set up again by calling SetAlarm and passing the context, just received from the first on receive method. SetAlarm(Context context, Bundle bundle, long reminder)

As soon as the onReceive method in SetAlarm is called, it validates if the alarm has to be set to another time. If yes I call new SetAlarm(_context, newBundle, newTime); _context is again the context I just received from the onReceive method.

The problem is that the onReceive method is called continously. (at least in case a reschedule of the event is necessary, even without reboot)

How does the onReceive method recognize, when an alarm was fired. Is it possible that this happens because I'm passing the context received by the onReceive method to new SetAlarm(...) for the reschedule?

END Edit2

Thank you for your help!


You need to show as more code if you want help from us...we work in the dark right now... try to put this in manifest as a intent: <intent-filter > <action android:name="android.intent.action.BOOT_COMPLETED"/> <category android:name="android.intent.category.HOME"/> </intent-filter>

Need Your Help

which one will be given priority in Tomcat 6: index.html or index.jsp?

web-applications tomcat6

Our web app contains both index.html and index.jsp, and we use Apache Tomcat 6. When a request having the path till the context (for eg.,http://localhost:8080/mysite) comes to the tomcat which one ...

MS SQL Server's equivalent to PostgreSQL's EXPLAIN

sql-server-2008 sql-server-2008r2-express sqlprofiler

Is there a SQL Server equivalent to PostgreSQL's EXPLAIN command that I can run on SQL Server 2008 R2 Express (ie. without SQL Profiler)?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.