Intent myIntent = new Intent(taskiller.this, taskiller.class);
pendingIntent = PendingIntent.getService(taskiller.this, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
//Set taskiller at 20secs
calendar.add(Calendar.SECOND, 20);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() , pendingIntent);
Log.i("Securitas", "Set alarm to be triggered");
我希望我的服务在一段时间间隔后重新启动,但似乎不会发生。 有人可以建议吗?