0

My application has a feature of setting reminders.I am creating reminders like this

           Intent intent = new Intent(Context,ReminderActivity.class);

    intent.putExtra(ResolutionsListActivity.RESOLUTION_OBJECT, resolution);

    PendingIntent sender = PendingIntent.getBroadcast(
    ComposeResolutionActivity.this,intent,PendingIntent.FLAG_UPDATE_CURRENT);

          AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
    am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
            interval, sender);

resolution --- serializable object.

Here my ReminderActivity class extends broadcast receiver.

I declared my receiver in manifest like this

       < receiver android:name="com.webileapps.resolutions.ReminderActivity"
        android:process=":remote" />

In my reminderactivity class am catching the triggered alarm and showing the notification.

    public class ReminderActivity extends BroadcastReceiver {
private static final String TAG = "ReminderActivity";

@Override
public void onReceive(Context context, Intent intent) {
    // Toast.makeText(context, "Alarm set", Toast.LENGTH_SHORT).show();
    Resolution resolution = (Resolution) intent
                                    .getSerializableExtra(ResolutionsListActivity.RESOLUTION_OBJECT);

        showNotification(context, resolution);
}

I am passing the serializable object so that - whenever users taps on the reminder notification - i can load my activity with that object. However, I'm getting errors like - " Failure filling in extras" whenever alarm triggers.

Can anyone please point out what am I doing wrong?

Handroid
  • 399
  • 1
  • 2
  • 13
  • Why u r doing this and what u r trying to achieve? – AAnkit Aug 29 '13 at 15:49
  • Why are you using `android:process=":remote"`? – CommonsWare Aug 29 '13 at 16:38
  • #CommonsWare: I just followed Api demos alarm samples.There they declared android:process=":remote" for the alarm broadcast receivers – Handroid Aug 30 '13 at 02:27
  • @CommonsWare (Not actually to you, Mark, but noticed as I'm here that Handroid didn't use at symbol in replying to you). Handroid... see this [:remote clarification](http://stackoverflow.com/a/4413816/1620738). – UpLate Sep 27 '13 at 20:54

1 Answers1

1

I also have this problem, the broadcast is received but it always has a warning for "Failure filling in extras".

The solution is wrap your Parcelable in a Bundle and add the Bundle as extra to the PendingIntent.

The problem is that when executing the PendingIntent it needs to copy the intent extras to another intent, but to copy the Parcelables it needs to unparcel and parcel again and on unparcel it uses the default ClassLoader and not your class ClassLoader, so it doesn't find the class to unparcel. But if you wrap in a Bundle, it copy the whole Bundle to the intent and no unparcel is done.

Marcio Covre
  • 4,556
  • 2
  • 22
  • 24