我需要你宝贵的帮助;)
我有一个的Android服务即在后台运行该固定位置的装置周期性地(一个位置轮询).当我使用使用Google Play服务的新Android Location API更新代码时.让我们来看看服务:
public class NewLocationPollerService extends Service implements GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener
{
private LocationRequest mLocationRequest = null;
private LocationClient mLocationClient = null;
...
private class PollerThread extends WakefulThread
{
protected void onPreExecute()
{
if ( GooglePlayServicesUtility.areServicesConnected( NewLocationPollerService.this ) )
mLocationClient.requestLocationUpdates(mLocationRequest, intent);
}
protected void onPostExecute()
{
if ( GooglePlayServicesUtility.areServicesConnected( NewLocationPollerService.this ) )
mLocationClient.removeLocationUpdates(intent);
super.onPostExecute();
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
方法" areServicesConnected() "如下:
public class GooglePlayServicesUtility
{
private static final …Run Code Online (Sandbox Code Playgroud)