[英]locationClient.requestLocationUpdates doesn't fires Pending Intent in Kitkat
I have a code that works fine in Android 4.3 and below. 我有一个在Android 4.3及更低版本中运行良好的代码。 But the same code doesn't work in 4.4 android.
但是相同的代码在4.4 android中不起作用。 Please help if anyone knows about the issue.
如果有人知道这个问题,请帮忙。
Below is the code, 下面是代码,
@Override
public void onConnected(Bundle arg0) {
Log.i(TAG, "location client connected");
locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(2 * 60 * 1000);
locationRequest.setFastestInterval(1 *60 * 1000);
mIntentService = new Intent(context, MyService.class);
mPendingIntent = PendingIntent.getService(context, 0, mIntentService, PendingIntent.FLAG_UPDATE_CURRENT);
locationClient.requestLocationUpdates(locationRequest, mPendingIntent);
}
Below is my Service class, 以下是我的服务类,
public class MyService extends IntentService {
private String TAG = this.getClass().getSimpleName();
Context context;
public MyService () {
super("MyService ");
context = this;
}
public MyService (String name) {
super("MyService ");
}
@Override
protected void onHandleIntent(Intent intent) {
// my code
}
}
Lately I updated the google-play-service_lib
最近我更新了
google-play-service_lib
and changed the locationClient.requestLocationUpdates
method to LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, mPendingIntent);
并将
locationClient.requestLocationUpdates
方法更改为LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, mPendingIntent);
Now everything seems working fine on all versions. 现在一切似乎都适用于所有版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.