public static void createAlarms() {
totaltimetaken = totaltimetaken + timetaken;
totalcost = totalcost + costone;
cal = Calendar.getInstance();
//cal.add(Calendar.HOUR, alarmintervalint);
cal.add(Calendar.SECOND, alarmintervalint);
calintent = new Intent(this, AlarmBroadcastReceiver.class);
calpendingintent = PendingIntent.getBroadcast(this.getApplicationContext(), 12345, calintent, 0);
am = (AlarmManager)getSystemService(Activity.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, alarmintervalint, calpendingintent);
}
I have made this method static so I can call it an another class of the same project. I am getting an error on these lines:
calintent = new Intent(this, AlarmBroadcastReceiver.class);
calpendingintent = PendingIntent.getBroadcast(this.getApplicationContext(), 12345, calintent, 0);
am = (AlarmManager)getSystemService(Activity.ALARM_SERVICE);
1) Cannot use 'this' in a static context
2) Cannot make a static reference to the non-static method getSystemService(String) from the type
How would I solve these errors? Thanks a lot!