【发布时间】:2014-02-03 19:40:07
【问题描述】:
我是 android 开发的菜鸟,我正在尝试弄清楚如何使用 Fused Location Provider。我正在使用this 教程,并且按照教程所示实现没有问题。但是,现在我想从意图服务中获取我的最后一个位置。问题是 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{...
【问题讨论】:
标签: android location google-maps-android-api-2 google-play-services location-provider