I have a repeating alarm that is started in the class StartActivity. The package is psychsoft.gps.v1 The code does not seem to catch whether the alarm is started or not.
if ((PendingIntent.getBroadcast(con, 13336,
new Intent("psychsoft.gps.v1"),
PendingIntent.FLAG_NO_CREATE) != null))
{
Log.i("aaa", "Alarm is already active");
Toast.makeText(con, "alarm already active", Toast.LENGTH_SHORT).show();
}
Calendar calGPS = Calendar.getInstance();
Intent intentGPS = new Intent(con, AlarmReceiver.class);
intentGPS.putExtra("alarm_message", "gps");
PendingIntent senderGPS = PendingIntent.getBroadcast(this, 13336, intentGPS, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the AlarmManager service
AlarmManager amGPS = (AlarmManager) getSystemService(ALARM_SERVICE);
amGPS.setRepeating(AlarmManager.RTC_WAKEUP, calGPS.getTimeInMillis(),1000*60*5, senderGPS);
To test this code I run it once to schedule the alarm (installing the app). Then I run it again (by clicking the icon) to try to get the Toast, or Log output. I am getting neither. Why? I originally though the issue might be fixed by matching the request code of the PendingIntent to that of the if statement, but it did not solve the problem.