Problem in identifying which widget click is launching the activity?

by Tom Gibara » Tue, 09 Jun 2009 01:03:04 GMT

Sponsored Links
 In addition to including the appWidgetId as an extra, put it as the
PendingIntent requestCode too (assuming you aren't already using that
property of the PendingIntent for some other purpose) that will enable the
system to distinguish them.

2009/6/8 Akash Gupta <>


Other Threads

1. How to debug apk running on the device manually? (without the Eclipse debug feature)

Hi all,

I have set up my project such that I am compiling my android project
manually without the ADT plugin, I have removed the Android nature by
changing the .project file.
But this comes with a cost: I can not use the ADT debug feature (by right
clicking on Android project and Debug As->Android Application)
So the question is: How to manually initiate debug mode of my app on a real
device ?


2. Intent.putExtra (String name, String[] value) caching old value


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

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,

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.


3. Number of Submissions?

4. How to do debugging with breakpoints in my Android code?

5. Too many pattern attempts! HTC Magic locked out!

6. Using Intent on default Google Map

7. 3D Primitives in opengl ES (sphere)