我有类似以下内容的内容,用于IntentService
通过重复调用 aBroadcastReceiver
来轮询服务器更新:
AlarmManager pollManager;
Intent pollIntent;
PendingIntent pollPendingIntent;
...
pollIntent = new Intent(getActivity(), ActionUpdateReceiver.class);
pollIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
pollIntent.putExtra(RECEIVER, resultReceiver);
pollIntent.putExtra(USER, accountId);
// This is the crux of my question
pollIntent.putExtra(SOMETHING_THAT_UPDATES, updatingThing);
pollPendingIntent = PendingIntent.getBroadcast(getActivity(), ACTION_REQUEST,
pollIntent, PendingIntent.FLAG_CANCEL_CURRENT);
pollManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
POLL_INTERVAL, pollPendingIntent);
在轮询服务器和使用 aResultReceiver
获取服务器更新方面,上述方法效果很好。但是,我需要向轮询服务提供一些反馈,以便更改我的更新查询。
我应该如何向投票服务提供反馈?如果需要更新查询,我是否只需要取消当前警报并再次设置意图?有没有比取消更好的方法?