How to update sending data to a service using intent when the service is started by the alarm manager?

I am writing an Android application in which a user can select several stocks to view and receive alerts if an agreed predefined alert condition. Stock data is stored in 5 objects of the custom Parcelable class "alert" (one object per share and condition). Periodic data updates are performed through the service launched by AlarmManager. Alert objects are passed to the service by placing them in an Intent, which is placed in the PendingIntent AlarmManager.

    Intent intent = new Intent(this, UpdateService.class);
    Bundle b = new Bundle();
    saveAlertsToBundle(b);      
    intent.putExtras(b);
    intent.setData(Uri.parse("updateManager"));
    PendingIntent pendIntent = PendingIntent.getService(this,0,intent,0);

    // 1min intervall
    long intervall = DateUtils.MINUTE_IN_MILLIS * 1;
    // time of first start
    long firstStartDelay = DateUtils.SECOND_IN_MILLIS * 30;
    long firstStart = System.currentTimeMillis() + firstStartDelay;

    AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    // kill running
    am.cancel(pendIntent);
    //start new
    am.setRepeating(AlarmManager.RTC_WAKEUP,firstStart,intervall,pendIntent);

My problem:

, , . , , . , , . , , .

, , AlarmManager.

AlarmManager ( //kill running comment) , . , - , ? , uri , .

.

+5
1

, PendingIntent. PengingIntent s. :

PendingIntent pendIntent = PendingIntent.getService(this,0,intent,0);

PendingIntent, , ( Intent. PendingIntent Intent, , , . , extras. , , PendingIntent PendingIntent.getService() PendingIntent ( , ).

PendingIntent.getService() PendingIntent , , , , :

int requestCode = (int) System.currentTimeMillis(); // Create unique request code
PendingIntent pendIntent = PendingIntent.getService(this, requestCode, intent, 0);

requestCode PendingIntent.getService(), .

OP

. , PendingIntent . . :

// Create a PendingIntent (or update the existing PendingIntent with new values
PendingIntent pendIntent = PendingIntent.getService(this, 0, intent,
                      PendingIntent.FLAG_UPDATE_CURRENT);

AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
// cancel any pending alarms
am.cancel(pendIntent);
//start new
am.setRepeating(AlarmManager.RTC_WAKEUP,firstStart,intervall,pendIntent);
+2

All Articles