小编ang*_*0ne的帖子

新的Location API Android.错误"调用connect()并等待onConnected()被调用"

我需要你宝贵的帮助;)

我有一个的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)

android geolocation android-service android-location

1
推荐指数
1
解决办法
5287
查看次数