Thanks Lee.  I'll give that a shot and post the results.

On Sep 26, 5:14 am, Lee <lee.wil...@googlemail.com> wrote:
> Try using setData() to store your message instead of extras: that
> forces the Intent to be seen as a new one. Or you can keep using
> extras and
> create some other unique token every time for setData().
>
> Lee
>
> p.s. also see the flags you can use at the end of the getService call
> (read
> the PendingIntent docs). There's something like
> 'FLAG_REPLACE_CURRENT'.
>
> On Sep 25, 9:39 pm, "Jason B." <jason.ba...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I'm creating an intent that I'm pushing to the AlarmManager so that a
> > service will be run at a later time.  I have a single string value I
> > need to pass with the intent so the service knows what to "do" when
> > it's onStart() is called.
>
> > Here is the code that sets up my intent and pushes it to the
> > AlarmManager
>
> > Intent myintent = new Intent();
> > myintent.setClass(mContext, RemindMeLater_Service.class);
> > myintent.putExtra("ReminderText", mEditText_Reminder.getText().toString
> > ());
> > mPendingIntent = PendingIntent.getService(this, 0, myintent, 0);
>
> > // Use the AlarmManager to schedule the PendingIntent
> > mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, alarmTime,
> > mPendingIntent);
>
> > Notice the line:
>
> > myintent.putExtra("ReminderText", mEditText_Reminder.getText().toString
> > ());
>
> > Essentially I'm trying to "change" the extended data referenced by the
> > same name in the putExtra call.  Note also that the "myintent" Intent
> > is freshly created everytime this block of code executes, so it should
> > be a new instantiated Intent object.  The text that is put into the
> > extended data comes from an EditText view on my activity.
>
> > The code in the service that is trying to pull the string out is:
>
> >  public void onStart(Intent intent, int startId) {
>
> >         // Increment mReminderId to ensure each notification is unique to
> > this context
> >         String reminderText = intent.getStringExtra("ReminderText");
>
> >         //do stuff with the "reminderText" we just got out of the intent
> >        // ...........
> >     }
>
> > Seems pretty simple, and logical.  So here comes the problem.  This
> > works ONCE.  The first time the intent is created and the extended
> > data is added with .putExtra(  ), when the AlarmManager goes off and
> > starts the service, the remidnerText is exactly what I put in.
> > However, subsequent calls to this code, creating the intent, adding a
> > new string using .putExtra( ), the AlarmManager goes off, service gets
> > onStart() called, now the reminderText still has the same value from
> > the first call.  It keeps holding onto the same value for ever until I
> > uninstall the .apk and reinstall (i.e. Rebuild ->Run through eclipse
> > on the emulator or a real device).
>
> > I've tried putting breakpoints right at this line and verified the new
> > string being passed into putExtra() has changed:
>
> > myintent.putExtra("ReminderText", mEditText_Reminder.getText().toString
> > ());
>
> > And then a breakpoint at the service line and verified that it still
> > has the previous value:
>
> > String reminderText = intent.getStringExtra("ReminderText");
>
> > I'm a little lost at what to do next.  Maybe the bundle that is
> > created is when I call putExtra() is being cached?  I've tried doing
> > System.gc() right before I create my new intent each time and still no
> > luck.  Thanks for any insight, I hope I've provided enough detail.
--~--~---------~--~----~------------~-------~--~----~
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