我如何在服务中实现以下方法,我希望它每 1 分钟工作一次(如果对应于当前时间,代码是检查天小时 mint 做某事)我看到了很多问题但没有用,请帮助。谢谢
{String[] columns = new String[] { KEY_ROWID, KEY_chNAME, KEY_prNAME, KEY_Rerun, KEY_HOUR, KEY_MINUTE, KEY_SUN, KEY_MON, KEY_TUE, KEY_WED, KEY_THU, KEY_FRI, KEY_SAT }; 光标 c = ourdatabase.query(DATABASE_TABLE, columns, null, null, null,null, null); 字符串结果 = "";
Calendar cl = Calendar.getInstance();
int today = cl.get(Calendar.DAY_OF_WEEK);
// String mStr="";
// mStr=mStr.concat("<body>");
// mStr=mStr.concat("<table border='1' ><tr> <th style='width:5px></th><td align='center'><b> Channal </b></td><td align='center'><b> Program </b></td><td align='center'><b> Time </b></tr>");
int iRow = c.getColumnIndex(KEY_ROWID);
int iCh = c.getColumnIndex(KEY_chNAME);
int ipr = c.getColumnIndex(KEY_prNAME);
int iHr = c.getColumnIndex(KEY_HOUR);
int iMin = c.getColumnIndex(KEY_MINUTE);
int iRerun = c.getColumnIndex(KEY_Rerun);
int iSun = c.getColumnIndex(KEY_SUN);
int iMon = c.getColumnIndex(KEY_MON);
int iTue = c.getColumnIndex(KEY_TUE);
int iWed = c.getColumnIndex(KEY_WED);
int iThu = c.getColumnIndex(KEY_THU);
int iFri = c.getColumnIndex(KEY_FRI);
int iSat = c.getColumnIndex(KEY_SAT);
DecimalFormat twoDigits = new DecimalFormat( "00" );
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
if (today == Integer.parseInt(c.getString(iSun))) {
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+ twoDigits.format(Integer.parseInt(c.getString(iMin))) + " " + c.getString(iRerun) + "\n";
}
else if (today == Integer.parseInt(c.getString(iMon))) {
//int mm=Integer.parseInt( twoDigits.format(Integer.parseInt(c.getString(iMin))));
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+ twoDigits.format(Integer.parseInt(c.getString(iMin))) + " " + c.getString(iRerun) + "\n";
}
else if (today == Integer.parseInt(c.getString(iTue))) {
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+ twoDigits.format(Integer.parseInt(c.getString(iMin)))+ " " + c.getString(iRerun) + "\n";
}
else if (today == Integer.parseInt(c.getString(iWed))) {
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+ twoDigits.format(Integer.parseInt(c.getString(iMin))) + " " + c.getString(iRerun) + "\n";
}
else if (today == Integer.parseInt(c.getString(iThu))) {
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+ twoDigits.format(Integer.parseInt(c.getString(iMin))) + " " + c.getString(iRerun) + "\n";
}
else if (today == Integer.parseInt(c.getString(iFri))) {
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+ twoDigits.format(Integer.parseInt(c.getString(iMin))) + " " + c.getString(iRerun) + "\n";
}
else if (today == Integer.parseInt(c.getString(iSat))) {
result += c.getString(iRow) + " - " + c.getString(iCh) + "\t "
+ c.getString(ipr) + "\t " + c.getString(iHr) + ":"
+twoDigits.format(Integer.parseInt(c.getString(iMin))) + " " + c.getString(iRerun) + "\n";
}
}
c.close(); }