1
我需要幫助。我新來android編碼。android alarmmanager +任務計劃
我已經做好了任務列表,我想在任務中寫下具體的東西。
這是我的任務項
private long id;
private int mon;
private int tues;
private int wednes;
private int thurs;
private int fri;
private int satur;
private int sun;
private int profile;
在那裏我有天(星期一,星期二等)持有分鐘的量(10:00其600)。
以下一些教程我已經報警reciever
public class AlarmReciever extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
try {
Bundle bundle = intent.getExtras();
String message = bundle.getString("alarm_message");
Intent newIntent = new Intent(context, AlarmActivity.class);
newIntent.putExtra("profile", message);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
} catch (Exception e) {
Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
它仍未經編輯...
然後還有哪些電話要報警經理
// get a Calendar object with current time
Calendar cal = Calendar.getInstance();
// add 5 minutes to the calendar object
cal.add(Calendar.MINUTE, 5);
Intent intent = new Intent(ctx, AlarmReceiver.class);
intent.putExtra("alarm_message", "O'Doyle Rules!");
// In reality, you would want to have a static variable for the request code instead of 192837
PendingIntent sender = PendingIntent.getBroadcast(this, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the AlarmManager service
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
我新任務的代碼不明白如何在日曆中指定,我需要在每個星期一的10:00重複(例如)新任務,並且在發生這種情況時,它會調用新函數,並將其設置爲「profile」variab與之合作。
private void setProfile(Integer profile)
{
// Doing things with profile
}
嗨,你需要問這裏的具體問題SO。像我這樣做,這和我運行的代碼,我得到這個錯誤,所以我的問題是這樣的。 –