I’ve the class:
PendingIntent pendingIntent;
public class xxx{
public void updateObjects(){
deleteIntents(Context context, int x);
(...)
for(...){
//Update each object ofdb4o with the new object value's.
(...)
doIntents(context,mil,obj);
}
(...)
}
public void doIntents(Context context, long mil, ClassObjects obj){
(...)
pendingIntent = PendingIntent.getBroadcast(context, obj.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
(...)
}
}
public void deleteIntents(Context context, int x){
intent = new Intent(context, OnAlarmReceiver.class);
for(int i=1;i<x;i++){
pendingIntent = PendingIntent.getBroadcast(context, i, intent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.cancel(pendingIntent);
}
Log.d(TAG,"intents removed");
}
And work’s Ok.. But I need use deleteIntents(Context context, int x) from main Activity.. With a button:
xxx.deleteIntents(getApplicationContext(),x);
But doesn’t work.. I think that I’ve a problem with the context but I don’t know why..
Can anybody help me please?
Sorry,
I had forgotten to instantiate the AlarmManager before:
Now Work’s!! Thank you both!!!!!