我想在 10 秒后杀死我的应用程序,我想在获得 Kill Action 后启动杀死应用程序的服务。但是这段代码在 10 秒后注意到。为什么?
AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, service_MyService.class);
intent.setAction("Kill");
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,intent, 0);
Calendar time = Calendar.getInstance();
time.setTimeInMillis(System.currentTimeMillis());
time.add(Calendar.SECOND, 10);
alarmMgr.set(AlarmManager.RTC_WAKEUP, time.getTimeInMillis(),pendingIntent);