Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓系统:;递归的;意向服务?_Android_Alarm_Schedule_Intentservice - Fatal编程技术网

Android 安卓系统:;递归的;意向服务?

Android 安卓系统:;递归的;意向服务?,android,alarm,schedule,intentservice,Android,Alarm,Schedule,Intentservice,启动IntentService的正确方法是什么?我进行递归调用,因为我需要更改报警信号 public class AlarmIntentService extends IntentService{ @Override protected void onHandleIntent(Intent intent){ SharedPreferences spf = getSharedPreferences("PREF_SOMETHING", MODE_PRIVATE);

启动IntentService的正确方法是什么?我进行递归调用,因为我需要更改报警信号

public class AlarmIntentService extends IntentService{
   @Override
   protected void onHandleIntent(Intent intent){
      SharedPreferences spf = getSharedPreferences("PREF_SOMETHING", MODE_PRIVATE);

      intent = new Intent(this, AlarmIntentService.class);
      PendingIntent pIntent = PendingIntent.getService(this, 0, intent, 0);
      AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + spf.getInt("TIME", 1) * 10000, pIntent);
   }
}

是的,这没问题。我所看到的唯一威胁是意外运行多个独立“线程”的可能性