我是 android 开发的菜鸟,我正在尝试弄清楚如何使用 Fused Location Provider。我正在使用本教程,并且按照教程所示实施没有问题。但是,现在我想从意图服务中获取我的最后一个位置。问题是 Location Client 的新实例不接受 context 或 context.getApplicationContext() 作为 ConnectionCallbacks 和 ConnectionFailedListner 的参数。GooglePlayServicesClient.ConnectionCallbacks 和 GooglePlayServicesClient.OnConnectionFailedListener 是通过它们附带的方法实现的。任何帮助是极大的赞赏。
我的代码
public class GCMIntentService extends GCMBaseIntentService implements GooglePlayServicesClient.ConnectionCallbacks,GooglePlayServicesClient.OnConnectionFailedListener,LocationListener{...
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
//Checking for message type
//Received geofence coordinates
if (message.contains("Your parent is acquiring your current location")){
c = context;
//Force get location
locationclient = new LocationClient(c,c,c);//<--Not working
locationclient = new LocationClient(c,c.getApplicationContext(),c.getApplicationContext());//<--Not working
locationrequest = LocationRequest.create();
locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationclient.connect();
}else{...