也许有一些非常简单,我没有看到。我试图从一些API调用一个方法,并且这个方法要求一个PendingIntent异步地给我发送一些值。我已经阅读了半小时的文档和示例,并且无法用简单的方式来包装我的头。最简单的方式使用/创建PendingIntent
更确切地说,我想调用ActivityRecognitionApi。 为了说明,这里是我如何从一个类似的API接收位置:
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient,
mLocationRequest,
new LocationListener() {
@Override
public void onLocationChanged(Location location) {
// I can do something with the location
}
});
所以我想这样做,以接收识别的活动:
ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(mGoogleApiClient,
1000,
// ... what here ?);
那么会是什么简单的方法创建一个pendingIntent来接收值?我试图创建一个匿名的PendingIntent,但该类是最终的。我不想开始一个服务,或活动,或广播任何东西......是否有一个简单的方法来创建这个PendingIntent来执行一段代码?
由于提前,