在服务

时间:2016-01-28 17:54:01

标签: android google-plus google-cloud-storage google-api-client google-drive-android-api

我试图在服务中实现GoogleApiClient

   public class SGoogle extends Service implements
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener {
    //...
    @Override
        public void onConnectionFailed(ConnectionResult result) {
            Log.i(TAG, "GoogleApiClient connection failed: " + result.toString());
            setConnected(false);
            if (!result.hasResolution()) {
                // show the localized error dialog.
                GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
                return;
            }
            try {
                result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
            } catch (SendIntentException e) {
                Log.e(TAG, "Exception while starting resolution activity", e);
            }
        }
    }

但是很明显,需要使用Activity来执行功能: GooglePlayServicesUtil.getErrorDialogresult.startResolutionForResult。有没有办法避免这种互动?或者可能是一些示例,以避免使用Activity来与服务的连接进行交互?有人解决了这个问题吗?

0 个答案:

没有答案