I need your help! When I put extras in my Intent and then I use that Intent to create a Pending Intent it doesn't work! I don't enter to the BroadCastReceiver class.
public class Recordatori_Visita extends Activity {
public void setAlarm(Calendar targetCal) {
Intent intent = new Intent (Recordatori_Visita.this, Receiver.class);
Long targetCal2 = targetCal.getTimeInMillis();
intent.putExtra("targetCal",targetCal2);
intent.putExtra("n",n);
PendingIntent pendingIntent = PendingIntent.getBroadcast(Recordatori_Visita.this, 1, intent, intent.FILL_IN_DATA);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),pendingIntent);
}
}
.
public class Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context k1, Intent k2) {
// TODO Auto-generated method stub
Bundle bolsaR = k2.getExtras();
Long extras = bolsaR.getLong("targetCalKey");
int n= bolsaR.getInt("n");
NotificationManager notificationManager = (NotificationManager) k1.getSystemService(Context.NOTIFICATION_SERVICE);
...
notificationManager.notify(1,myNotification);
}
}
I've cut the code, all the variables used are created, I can't find the solution. If I don't put extra data in the intent it works fine but when I putExtra it doesn't work because there is no notification. Thanks!!