I call a BroadcastReceiver from an Activity
Intent alarmIntent = new Intent(MainActivity.this, AlarmRec.class);
alarmIntent.putExtra("lol",0);
pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, alarmIntent, 0);
AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
manager.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+5000, pendingIntent);
Its onReceivemethod is this:
int lol=intent.getExtras().getInt("lol");
Toast.makeText(context, "I'm running "+lol, Toast.LENGTH_SHORT).show();
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
lol++;
Intent alarmIntent = new Intent(context, AlarmRec.class);
alarmIntent.putExtra("lol",lol);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
manager.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+5000, pendingIntent);
Basially, every time the Receiver is called, it should show a Toast It's Running plus an incremented value(1,2,3 etc). However, it always shows It's Running 0. What am I doing wrong?