I want to have an action (the one in Runnable) that runs in the background even after the app gets killed. I have errors at r inThread t = new Thread(r);
(in Thread cannot be applied java Runnable) and at t.start();
(cannot resolve method)
This is in onCreate()
Runnable r = new Runnable() {
@Override
public void run() {
Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
SharedPreferences sharedPref = getSharedPreferences("Alarms", Context.MODE_PRIVATE);
mh = sharedPref.getInt("morningHour", hour_x );
mm = sharedPref.getInt("morningMinute", minute_x );
int hours = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE) ;
if(hours == mh && minutes == mm)
startAlarm();
nh = sharedPref.getInt("noonHour", hour_x );
nm = sharedPref.getInt("noonMinute", minute_x );
if(hours == nh && minutes == nm)
startAlarm();
eh = sharedPref.getInt("eveningHour", hour_x );
em = sharedPref.getInt("eveningMinute", minute_x );
if(hours == eh && minutes == em)
startAlarm();
}
};
Thread t = new Thread(r);
t.start();