Android 在位置请求PendingEvent中包含数据

Android 在位置请求PendingEvent中包含数据,android,android-intent,Android,Android Intent,我正在请求一系列位置更新,包括pendingent,设置了BroadcastReceiver以处理位置更新。下面是一个示例pendingent: Intent locationIntent = new Intent(context, LocationReceiver.class); locationIntent.putExtra("foo", "bar"); pendingIntent = PendingIntent.getBroadcast(context, 0, lo

我正在请求一系列位置更新,包括
pendingent
,设置了
BroadcastReceiver
以处理位置更新。下面是一个示例
pendingent

    Intent locationIntent = new Intent(context, LocationReceiver.class);
    locationIntent.putExtra("foo", "bar");
    pendingIntent = PendingIntent.getBroadcast(context, 0, locationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
以下是请求位置更新的代码:

    final LocationRequest request = LocationRequest.create();
    request.setInterval(UPDATE_INTERVAL);
    request.setExpirationDuration(WAKEUP_DELTA * 2);
    request.setNumUpdates(NUM_UPDATES);
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    request.setLocationServices.FusedLocationApi.requestLocationUpdates(locationClient, request, pendingIntent);
问题是:似乎如果我在意图中包含任何额外的内容,那么位置就不会包含在内。也就是说,当我调用
intent.getExtras().get(FusedLocationProviderApi.KEY\u LOCATION\u CHANGED)时结果为空。如果我没有在我的
意图中添加额外内容
,则
位置
将出现在额外内容中


我尝试了各种变通方法,包括的各种迭代,但这似乎对我不起作用。有没有什么方法可以解决这个问题,而不是想出一些方法将多余的存储在别处,并在执行位置接收器时检索它们?还是我明显做错了什么?

很抱歉这么晚才回答。但对于那些可能仍在寻找答案的人来说,我找到了答案:-
LocationResult和LocationAvailability都会发送到给定的挂起内容。您可以使用hasResult(意图)、extractResult(意图)、hasLocationAvailability(意图)和extractLocationAvailability(意图)从意图中提取数据。
之后,只需使用LocationCallbacks内部使用的代码。

你能找到解决这个问题的方法吗@Catherine?