我正在安排这样的警报管理器:
Intent myIntent = new Intent(context, Locale.class);
intent.putExtra("end",AlarmEnd.getTimeInMillis());
PendingIntent pendingIntent = PendingIntent.getService(context, 0, myIntent, PendingIntent.FLAG_CANCEL_CURRENT);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, AlarmStart.getTimeInMillis(), 40 * 1000, pendingIntent);
所以这是有效的......问题是它何时启动 Locale
public int onStartCommand(Intent intent, int flags, int startId) {
int t = START_STICKY;
SharedPreferences alarms = getApplicationContext().getSharedPreferences("alarms", 0);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Log.i("LocalService", "Received start id " + startId + ": " + intent);
client = new AsyncHttpClient();
endTime = intent.getLongExtra("end",0);
Log.d("Alarms", "End time is".concat(endTime.toString()));
调试消息总是输出默认值“结束时间为 0”。我知道额外的意图不是零(检查它)。我究竟做错了什么?