Example usage for android.os ResultReceiver send

List of usage examples for android.os ResultReceiver send

Introduction

In this page you can find the example usage for android.os ResultReceiver send.

Prototype

public void send(int resultCode, Bundle resultData) 

Source Link

Document

Deliver a result to this receiver.

Usage

From source file:com.haibison.android.lockpattern.LockPatternFragment.java

/**
 * Finishes the activity with negative result (
 * {@link Activity#RESULT_CANCELED}, {@link #RESULT_FAILED} or
 * {@link #RESULT_FORGOT_PATTERN})./*w  w  w .  j  av a  2 s  . c o  m*/
 */
private void finishWithNegativeResult(int resultCode) {
    if (ACTION_COMPARE_PATTERN.equals(fa.getIntent().getAction()))
        mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount);

    fa.setResult(resultCode, mIntentResult);

    /*
     * ResultReceiver
     */
    ResultReceiver receiver = fa.getIntent().getParcelableExtra(EXTRA_RESULT_RECEIVER);
    if (receiver != null) {
        Bundle resultBundle = null;
        if (ACTION_COMPARE_PATTERN.equals(fa.getIntent().getAction())) {
            resultBundle = new Bundle();
            resultBundle.putInt(EXTRA_RETRY_COUNT, mRetryCount);
        }
        receiver.send(resultCode, resultBundle);
    }

    /*
     * PendingIntent
     */
    PendingIntent pi = fa.getIntent().getParcelableExtra(EXTRA_PENDING_INTENT_CANCELLED);
    if (pi != null) {
        try {
            pi.send(getActivity(), resultCode, mIntentResult);
        } catch (Throwable t) {
            Log.e(CLASSNAME, "Error sending PendingIntent: " + pi, t);
        }
    }

    fa.finish();
}

From source file:com.ubuntuone.android.files.service.MetaService.java

public void onFailure(U1Failure failure, ResultReceiver receiver) {
    int statusCode = failure.getStatusCode();
    Log.e(TAG, "onFailure: " + failure.toString() + ", HTTP " + statusCode);
    Bundle data;/* www  . ja  v a  2  s  .c  o  m*/
    switch (statusCode) {
    case HttpStatus.SC_UNAUTHORIZED:
        Preferences.invalidateToken(this);

        Intent intent = new Intent("com.ubuntuone.android.files.SIGN_OUT");
        LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
        stopSelf();
        break;
    case HttpStatus.SC_NOT_FOUND:
        data = new Bundle();
        data.putString(EXTRA_ERROR, "Resource not found.");
        receiver.send(Status.ERROR, data);
        break;
    case HttpStatus.SC_INTERNAL_SERVER_ERROR:
        data = new Bundle();
        data.putString(EXTRA_ERROR, "Server error. Please try again later.");
        receiver.send(Status.ERROR, data);
        break;

    default:
        // TODO GA?
        break;
    }
}

From source file:com.haibison.android.lockpattern.LockPatternFragment.java

/**
 * Finishes activity with {@link Activity#RESULT_OK}.
 *
 * @param pattern/*from w  ww  .j  a v  a  2s  .c  om*/
 *            the pattern, if getActivity() is in mode creating pattern. In any
 *            cases, it can be set to {@code null}.
 */
private void finishWithResultOk(char[] pattern) {
    if (ACTION_CREATE_PATTERN.equals(fa.getIntent().getAction()))
        mIntentResult.putExtra(EXTRA_PATTERN, pattern);
    else {
        /*
         * If the user was "logging in", minimum try count can not be zero.
         */
        mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount + 1);
    }

    fa.setResult(fa.RESULT_OK, mIntentResult);

    /*
     * ResultReceiver
     */
    ResultReceiver receiver = fa.getIntent().getParcelableExtra(EXTRA_RESULT_RECEIVER);
    if (receiver != null) {
        Bundle bundle = new Bundle();
        if (ACTION_CREATE_PATTERN.equals(fa.getIntent().getAction()))
            bundle.putCharArray(EXTRA_PATTERN, pattern);
        else {
            /*
             * If the user was "logging in", minimum try count can not be
             * zero.
             */
            bundle.putInt(EXTRA_RETRY_COUNT, mRetryCount + 1);
        }
        receiver.send(fa.RESULT_OK, bundle);
    }

    /*
     * PendingIntent
     */
    PendingIntent pi = fa.getIntent().getParcelableExtra(EXTRA_PENDING_INTENT_OK);
    if (pi != null) {
        try {
            pi.send(getActivity(), fa.RESULT_OK, mIntentResult);
        } catch (Throwable t) {
            Log.e(CLASSNAME, "Error sending PendingIntent: " + pi, t);
        }
    }

    fa.finish();
}

From source file:com.ubuntuone.android.files.service.MetaService.java

/**
 * Given parents resource path and {@link ArrayList} of {@link NodeInfo}s of
 * its children, syncs cached info of these children. Updating children in
 * one method enables us to make use of database transaction.<br />
 * <ul>/*from   w ww . ja  v a  2 s .c o  m*/
 * <li>- inserts if child is new</li>
 * <li>- updates if child has changed [thus marks is_cached = false]</li>
 * <li>- deletes if child is missing [dead node]</li>
 * </ul>
 * 
 * @param parentResourcePath
 *            the resource path of childrens parent
 * @param children
 *            {@link NodeInfo}s of the parents children
 * @throws OperationApplicationException 
 * @throws RemoteException 
 */
public void getDirectoryNode(final String resourcePath, final ResultReceiver receiver) {
    Log.i(TAG, "getDirectoryNode()");
    final String[] projection = new String[] { Nodes._ID, Nodes.NODE_RESOURCE_PATH, Nodes.NODE_GENERATION,
            Nodes.NODE_DATA };
    final String selection = Nodes.NODE_RESOURCE_PATH + "=?";

    final Set<Integer> childrenIds = MetaUtilities.getChildrenIds(resourcePath);

    final ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();

    final Bundle data = new Bundle();
    data.putString(EXTRA_RESOURCE_PATH, resourcePath);

    api.listDirectory(resourcePath, new U1NodeListener() {
        @Override
        public void onStart() {
            if (receiver != null)
                receiver.send(Status.RUNNING, data);
        }

        @Override
        public void onSuccess(U1Node node) {
            if (node.getKind() == U1NodeKind.FILE && ((U1File) node).getSize() == null) {
                // Ignore files with null size.
                return;
            }
            final String[] selectionArgs = new String[] { node.getResourcePath() };
            final Cursor c = contentResolver.query(Nodes.CONTENT_URI, projection, selection, selectionArgs,
                    null);
            try {
                ContentValues values = Nodes.valuesFromRepr(node);
                if (c.moveToFirst()) {
                    final int id = c.getInt(c.getColumnIndex(Nodes._ID));
                    // Node is live.
                    childrenIds.remove(id);

                    // Update node.
                    final long generation = c.getLong(c.getColumnIndex(Nodes.NODE_GENERATION));
                    final long newGeneration = node.getGeneration();
                    if (generation < newGeneration) {
                        Log.v(TAG, "updating child node, new generation");
                        values.put(Nodes.NODE_IS_CACHED, false);
                        values.put(Nodes.NODE_DATA, "");

                        String data = c.getString(c.getColumnIndex(Nodes.NODE_DATA));
                        FileUtilities.removeSilently(data);

                        Uri uri = MetaUtilities.buildNodeUri(id);
                        ContentProviderOperation op = ContentProviderOperation.newUpdate(uri).withValues(values)
                                .build();
                        operations.add(op);
                        if (operations.size() > 10) {
                            try {
                                contentResolver.applyBatch(MetaContract.CONTENT_AUTHORITY, operations);
                                operations.clear();
                            } catch (RemoteException e) {
                                Log.e(TAG, "Remote exception", e);
                            } catch (OperationApplicationException e) {
                                MetaUtilities.setIsCached(resourcePath, false);
                                return;
                            }
                            Thread.yield();
                        }
                    } else {
                        Log.v(TAG, "child up to date");
                    }
                } else {
                    // Insert node.
                    Log.v(TAG, "inserting child");
                    ContentProviderOperation op = ContentProviderOperation.newInsert(Nodes.CONTENT_URI)
                            .withValues(values).build();
                    operations.add(op);
                    if (operations.size() > 10) {
                        try {
                            contentResolver.applyBatch(MetaContract.CONTENT_AUTHORITY, operations);
                            operations.clear();
                        } catch (RemoteException e) {
                            Log.e(TAG, "Remote exception", e);
                        } catch (OperationApplicationException e) {
                            MetaUtilities.setIsCached(resourcePath, false);
                            return;
                        }
                        Thread.yield();
                    }
                }
            } finally {
                c.close();
            }
        }

        @Override
        public void onUbuntuOneFailure(U1Failure failure) {
            MetaService.this.onUbuntuOneFailure(failure, receiver);
        }

        @Override
        public void onFailure(U1Failure failure) {
            MetaService.this.onFailure(failure, receiver);
        }

        @Override
        public void onFinish() {
            if (receiver != null)
                receiver.send(Status.FINISHED, data);
        }
    });

    // Remove nodes, which ids are left in childrenIds set.
    if (!childrenIds.isEmpty()) {
        Log.v(TAG, "childrenIDs not empty: " + childrenIds.size());
        final Iterator<Integer> it = childrenIds.iterator();
        while (it.hasNext()) {
            int id = it.next();
            Uri uri = MetaUtilities.buildNodeUri(id);
            ContentProviderOperation op = ContentProviderOperation.newDelete(uri).build();
            operations.add(op);
        }
    } else {
        Log.v(TAG, "childrenIDs empty");
    }

    try {
        long then = System.currentTimeMillis();
        contentResolver.applyBatch(MetaContract.CONTENT_AUTHORITY, operations);
        MetaUtilities.setIsCached(resourcePath, true);
        long now = System.currentTimeMillis();
        Log.d(TAG, "time to update children: " + (now - then));
        contentResolver.notifyChange(Nodes.CONTENT_URI, null);
    } catch (RemoteException e) {
        Log.e(TAG, "", e);
    } catch (OperationApplicationException e) {
        MetaUtilities.setIsCached(resourcePath, false);
        return;
    }
}

From source file:se.leap.bitmaskclient.ProviderAPI.java

@Override
protected void onHandleIntent(Intent command) {
    final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY);
    String action = command.getAction();
    Bundle parameters = command.getBundleExtra(PARAMETERS);

    if (provider_api_url == null && preferences.contains(Provider.KEY)) {
        try {//from  w ww . ja v  a 2  s .  c  o m
            JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, ""));
            provider_api_url = provider_json.getString(Provider.API_URL) + "/"
                    + provider_json.getString(Provider.API_VERSION);
            go_ahead = true;
        } catch (JSONException e) {
            go_ahead = false;
        }
    }

    if (action.equalsIgnoreCase(SET_UP_PROVIDER)) {
        Bundle result = setUpProvider(parameters);
        if (go_ahead) {
            if (result.getBoolean(RESULT_KEY)) {
                receiver.send(PROVIDER_OK, result);
            } else {
                receiver.send(PROVIDER_NOK, result);
            }
        }
    } else if (action.equalsIgnoreCase(SIGN_UP)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources);
        Bundle result = tryToRegister(parameters);
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(SUCCESSFUL_SIGNUP, result);
        } else {
            receiver.send(FAILED_SIGNUP, result);
        }
    } else if (action.equalsIgnoreCase(LOG_IN)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources);
        Bundle result = tryToAuthenticate(parameters);
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(SUCCESSFUL_LOGIN, result);
            UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources);
        } else {
            receiver.send(FAILED_LOGIN, result);
            UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources);
        }
    } else if (action.equalsIgnoreCase(LOG_OUT)) {
        UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources);
        if (logOut()) {
            receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY);
            UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources);
        } else {
            receiver.send(LOGOUT_FAILED, Bundle.EMPTY);
            UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources);
        }
    } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) {
        if (updateVpnCertificate()) {
            receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
        } else {
            receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY);
        }
    } else if (action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) {
        Bundle result = getAndSetEipServiceJson();
        if (result.getBoolean(RESULT_KEY)) {
            receiver.send(CORRECTLY_DOWNLOADED_EIP_SERVICE, result);
        } else {
            receiver.send(INCORRECTLY_DOWNLOADED_EIP_SERVICE, result);
        }
    }
}

From source file:fr.eyal.lib.data.service.DataLibService.java

/**
 * Send the result of a request to the linked {@link ServiceHelper}
 * /*from   w w  w. jav a  2  s.  c o m*/
 * @param request the request
 * @param response the response
 * @param code the status of the request
 */
protected void sendResult(final DataLibRequest request, final BusinessResponse response, final int code) {
    Out.d(TAG, "sendResult");

    final Intent intent = request.intent;
    final ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra(INTENT_EXTRA_RECEIVER);

    if (receiver != null) {
        final Bundle b = new Bundle();

        if (response != null && response.response != null) {

            //if the Business Object have to be transmit inside the Bundle
            if (request.isParcelableMethodEnabled())
                b.putParcelable(ServiceHelper.RECEIVER_EXTRA_RESULT, response.response);

            //we add the request id to the response
            if (response.response instanceof ResponseBusinessObjectDAO) {
                ResponseBusinessObjectDAO r = (ResponseBusinessObjectDAO) response.response;
                b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, r._id);
            } else {
                //in case of no data cache, we set an invalid ID
                b.putLong(ServiceHelper.RECEIVER_EXTRA_RESULT_ID, BusinessObjectDAO.ID_INVALID);
            }

        } else {
            Out.e(TAG, "Unfined response");
        }

        //we copy the content of the response in the intent's bundle
        b.putInt(ServiceHelper.RECEIVER_EXTRA_REQUEST_ID, intent.getIntExtra(INTENT_EXTRA_REQUEST_ID, -1));
        b.putInt(ServiceHelper.RECEIVER_EXTRA_WEBSERVICE_TYPE,
                intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1));
        b.putInt(ServiceHelper.RECEIVER_EXTRA_RETURN_CODE, response.returnCode);
        b.putInt(ServiceHelper.RECEIVER_EXTRA_RESULT_CODE, response.status);
        b.putString(ServiceHelper.RECEIVER_EXTRA_RESULT_MESSAGE, "");

        receiver.send(code, b);
    }
}

From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Uri action = intent.getData();/*from  w ww.j  a  va 2s .  co m*/
    Bundle extras = intent.getExtras();

    if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) {
        Log.e(TAG, "You did not pass extras or data with the Intent.");
        return;
    }

    int verb = extras.getInt(EXTRA_HTTP_VERB, GET);
    Bundle params = extras.getParcelable(EXTRA_PARAMS);
    Bundle headers = extras.getParcelable(EXTRA_HEADERS);
    ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER);

    try {
        HttpRequestBase request = null;

        // Get query params from Bundle and build URL
        switch (verb) {
        case GET: {
            request = new HttpGet();
            attachUriWithQuery(request, action, params);
        }
            break;

        case DELETE: {
            request = new HttpDelete();
            attachUriWithQuery(request, action, params);
        }
            break;

        case POST: {
            request = new HttpPost();
            request.setURI(new URI(action.toString()));

            HttpPost postRequest = (HttpPost) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                postRequest.setEntity(formEntity);
            }
        }
            break;

        case PUT: {
            request = new HttpPut();
            request.setURI(new URI(action.toString()));

            HttpPut putRequest = (HttpPut) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                putRequest.setEntity(formEntity);
            }
        }
            break;
        }

        // Get Headers from Bundle
        for (BasicNameValuePair header : paramsToList(headers)) {
            request.setHeader(header.getName(), header.getValue());
        }

        if (request != null) {
            HttpClient client = new DefaultHttpClient();

            Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString());

            HttpResponse response = client.execute(request);

            HttpEntity responseEntity = response.getEntity();
            StatusLine responseStatus = response.getStatusLine();
            int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0;

            if ((responseEntity != null) && (responseStatus.getStatusCode() == 200)) {
                Bundle resultData = new Bundle();
                resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity));
                receiver.send(statusCode, resultData);
            } else {
                receiver.send(statusCode, null);
            }
        }
    } catch (URISyntaxException e) {
        Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e);
        receiver.send(0, null);
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e);
        receiver.send(0, null);
    } catch (ClientProtocolException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (IOException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:net.niyonkuru.koodroid.service.SessionService.java

@Override
public void onHandleIntent(Intent intent) {
    if (DEBUG)/* w w  w.  ja  v  a 2 s  . c  om*/
        Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")");

    int request = intent.getIntExtra(EXTRA_REQUEST, REQUEST_LOGIN);
    if (request == REQUEST_LOGOUT) {
        logout();
        return;
    }

    final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);

    final String email = intent.getStringExtra(EXTRA_EMAIL);
    final String password = intent.getStringExtra(EXTRA_PASSWORD);
    boolean broadcast = intent.getBooleanExtra(EXTRA_BROADCAST, false);

    /* totally ignore this request until full credentials are provided */
    if (email == null || password == null)
        return;

    final long startLogin = System.currentTimeMillis();
    final long lastLogin = mSettings.lastLogin();

    /* if the last successful login is within the last 15 minutes */
    if (startLogin - lastLogin <= DateUtils.MINUTE_IN_MILLIS * 15) {

        /* do a credentials check again the local data store */
        if (email.equals(mSettings.email()) && password.equals(mSettings.password())) {
            if (broadcast)
                IntentUtils.callWidget(this, LOGIN_FINISHED);
            announce(receiver, STATUS_FINISHED);
            return;
        }
    }

    try {
        if (NetworkUtils.isConnected(this)) {
            /* announce to the caller that we are now running */
            announce(receiver, STATUS_RUNNING);

        } else
            throw new ServiceException(getString(R.string.error_network_down));

        if (mSettings.email() == null) {
            /* this is likely a new user */
            Crittercism.leaveBreadcrumb(TAG + ": first_time_login");
        }

        login(email, password);
        saveCookies();

        if (DEBUG)
            Log.d(TAG, "login took " + (System.currentTimeMillis() - startLogin) + "ms");

    } catch (IOException e) {
        if (DEBUG)
            Log.e(TAG, "Problem while logging in", e);

        /* if the exception was simply from an abort */
        if (mPostRequest != null && mPostRequest.isAborted())
            return;

        if (receiver != null) {
            // Pass back error to surface listener
            final Bundle bundle = new Bundle();
            bundle.putString(Intent.EXTRA_TEXT, e.toString());
            receiver.send(STATUS_ERROR, bundle);
        }
        return; /* do not announce success below */
    }

    if (broadcast)
        IntentUtils.callWidget(this, LOGIN_FINISHED);
    announce(receiver, STATUS_FINISHED);
}

From source file:com.cloudbees.gasp.service.RESTService.java

@Override
protected void onHandleIntent(Intent intent) {
    // When an intent is received by this Service, this method
    // is called on a new thread.

    Uri action = intent.getData();//ww  w .j  a  v  a2  s  .c  o m
    Bundle extras = intent.getExtras();

    if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) {
        // Extras contain our ResultReceiver and data is our REST action.  
        // So, without these components we can't do anything useful.
        Log.e(TAG, "You did not pass extras or data with the Intent.");

        return;
    }

    // We default to GET if no verb was specified.
    int verb = extras.getInt(EXTRA_HTTP_VERB, GET);
    Bundle params = extras.getParcelable(EXTRA_PARAMS);
    ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER);

    try {
        // Here we define our base request object which we will
        // send to our REST service via HttpClient.
        HttpRequestBase request = null;

        // Let's build our request based on the HTTP verb we were
        // given.
        switch (verb) {
        case GET: {
            request = new HttpGet();
            attachUriWithQuery(request, action, params);
        }
            break;

        case DELETE: {
            request = new HttpDelete();
            attachUriWithQuery(request, action, params);
        }
            break;

        case POST: {
            request = new HttpPost();
            request.setURI(new URI(action.toString()));

            // Attach form entity if necessary. Note: some REST APIs
            // require you to POST JSON. This is easy to do, simply use
            // postRequest.setHeader('Content-Type', 'application/json')
            // and StringEntity instead. Same thing for the PUT case 
            // below.
            HttpPost postRequest = (HttpPost) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                postRequest.setEntity(formEntity);
            }
        }
            break;

        case PUT: {
            request = new HttpPut();
            request.setURI(new URI(action.toString()));

            // Attach form entity if necessary.
            HttpPut putRequest = (HttpPut) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                putRequest.setEntity(formEntity);
            }
        }
            break;
        }

        if (request != null) {
            HttpClient client = new DefaultHttpClient();

            // Let's send some useful debug information so we can monitor things
            // in LogCat.
            Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString());

            // Finally, we send our request using HTTP. This is the synchronous
            // long operation that we need to run on this thread.
            HttpResponse response = client.execute(request);

            HttpEntity responseEntity = response.getEntity();
            StatusLine responseStatus = response.getStatusLine();
            int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0;

            // Our ResultReceiver allows us to communicate back the results to the caller. This
            // class has a method named send() that can send back a code and a Bundle
            // of data. ResultReceiver and IntentService abstract away all the IPC code
            // we would need to write to normally make this work.
            if (responseEntity != null) {
                Bundle resultData = new Bundle();
                resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity));
                receiver.send(statusCode, resultData);
            } else {
                receiver.send(statusCode, null);
            }
        }
    } catch (URISyntaxException e) {
        Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e);
        receiver.send(0, null);
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e);
        receiver.send(0, null);
    } catch (ClientProtocolException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (IOException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    }
}