【发布时间】:2019-11-07 12:17:05
【问题描述】:
我正在使用pending intent 收听DetectedActivity、FusedLocation、GoogleFit 等更新。我过去了
PendingIntent.FLAG_UPDATE_CURRENT when calling: pendingIntent = PendingIntent.getService(this, 12, intentService, PendingIntent.FLAG_UPDATE_CURRENT);
但是,我仍然得到重复的数据。
我尝试在每次收听某些更新时使用不同的请求 ID(用于收听 FusedLocation 更新的不同请求 ID,用于收听 GoogleFit 更新的不同请求 ID 等),但它仍然给我重复的数据。我还尝试将不同的 actionIds 添加到 intentService
在我的服务中,我有以下代码:
intentService = new Intent(this, SensorsIntentService.class); //in onCreate
pendingIntent = PendingIntent.getService(this, 12, intentService, PendingIntent.FLAG_UPDATE_CURRENT);
我希望每次只有一组数据并且没有重复。 任何帮助,将不胜感激。
【问题讨论】:
标签: android android-service android-pendingintent google-fit android-fusedlocation