Example usage for android.net Uri encode

List of usage examples for android.net Uri encode

Introduction

In this page you can find the example usage for android.net Uri encode.

Prototype

public static String encode(String s) 

Source Link

Document

Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme.

Usage

From source file:com.android.gallery3d.filtershow.FilterShowActivity.java

@Override
public boolean onShareTargetSelected(ShareActionProvider arg0, Intent arg1) {
    // First, let's tell the SharedImageProvider that it will need to wait
    // for the image
    Uri uri = Uri.withAppendedPath(SharedImageProvider.CONTENT_URI,
            Uri.encode(mSharedOutputFile.getAbsolutePath()));
    ContentValues values = new ContentValues();
    values.put(SharedImageProvider.PREPARE, true);
    getContentResolver().insert(uri, values);
    mSharingImage = true;/*from  www .ja va 2 s.  co  m*/

    // Process and save the image in the background.
    showSavingProgress(null);
    mImageShow.saveImage(this, mSharedOutputFile);
    return true;
}

From source file:org.videolan.vlc.MediaDatabase.java

public synchronized void addNetworkFavItem(Uri uri, String title) {
    ContentValues values = new ContentValues();
    values.put(NETWORK_FAV_URI, uri.toString());
    values.put(NETWORK_FAV_TITLE, Uri.encode(title));
    mDb.replace(NETWORK_FAV_TABLE_NAME, null, values);
}

From source file:com.android.gallery3d.filtershow.FilterShowActivity.java

private Intent getDefaultShareIntent() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setType(SharedImageProvider.MIME_TYPE);
    mSharedOutputFile = SaveImage.getNewFile(this, MasterImage.getImage().getUri());
    Uri uri = Uri.withAppendedPath(SharedImageProvider.CONTENT_URI,
            Uri.encode(mSharedOutputFile.getAbsolutePath()));
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    return intent;
}

From source file:com.android.music.TrackBrowserFragment.java

private Cursor getTrackCursor(TrackListAdapter.TrackQueryHandler queryhandler, String filter, boolean async) {

    if (queryhandler == null) {
        throw new IllegalArgumentException();
    }//from   ww w . ja v a  2s  . co  m

    Cursor ret = null;
    mSortOrder = MediaStore.Audio.Media.TITLE_KEY;
    StringBuilder where = new StringBuilder();
    where.append(MediaStore.Audio.Media.TITLE + " != ''");

    if (mGenre != null) {
        Uri uri = MediaStore.Audio.Genres.Members.getContentUri("external", Integer.valueOf(mGenre));
        if (!TextUtils.isEmpty(filter)) {
            uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
        }
        mSortOrder = MediaStore.Audio.Genres.Members.DEFAULT_SORT_ORDER;
        ret = queryhandler.doQuery(uri, mCursorCols, where.toString(), null, mSortOrder, async);
    } else if (mPlaylist != null) {
        if (mPlaylist.equals("nowplaying")) {
            if (MusicUtils.sService != null) {
                ret = new NowPlayingCursor(MusicUtils.sService, mCursorCols);
                if (ret.getCount() == 0) {
                    getActivity().finish();
                }
            } else {
                // Nothing is playing.
            }
        } else if (mPlaylist.equals("podcasts")) {
            where.append(" AND " + MediaStore.Audio.Media.IS_PODCAST + "=1");
            Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            if (!TextUtils.isEmpty(filter)) {
                uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
            }
            ret = queryhandler.doQuery(uri, mCursorCols, where.toString(), null,
                    MediaStore.Audio.Media.DEFAULT_SORT_ORDER, async);
        } else if (mPlaylist.equals("recentlyadded")) {
            // do a query for all songs added in the last X weeks
            Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            if (!TextUtils.isEmpty(filter)) {
                uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
            }
            int X = MusicUtils.getIntPref(getActivity(), "numweeks", 2) * (3600 * 24 * 7);
            where.append(" AND " + MediaStore.MediaColumns.DATE_ADDED + ">");
            where.append(System.currentTimeMillis() / 1000 - X);
            ret = queryhandler.doQuery(uri, mCursorCols, where.toString(), null,
                    MediaStore.Audio.Media.DEFAULT_SORT_ORDER, async);
        } else {
            Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", Long.valueOf(mPlaylist));
            if (!TextUtils.isEmpty(filter)) {
                uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
            }
            mSortOrder = MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER;
            ret = queryhandler.doQuery(uri, mPlaylistMemberCols, where.toString(), null, mSortOrder, async);
        }
    } else {
        if (mAlbumId != null) {
            where.append(" AND " + MediaStore.Audio.Media.ALBUM_ID + "=" + mAlbumId);
            mSortOrder = MediaStore.Audio.Media.TRACK + ", " + mSortOrder;
        }
        if (mArtistId != null) {
            where.append(" AND " + MediaStore.Audio.Media.ARTIST_ID + "=" + mArtistId);
        }
        where.append(" AND " + MediaStore.Audio.Media.IS_MUSIC + "=1");
        Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
        if (!TextUtils.isEmpty(filter)) {
            uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
        }
        ret = queryhandler.doQuery(uri, mCursorCols, where.toString(), null, mSortOrder, async);
    }

    // This special case is for the "nowplaying" cursor, which cannot be handled
    // asynchronously using AsyncQueryHandler, so we do some extra initialization here.
    if (ret != null && async) {
        init(ret, false);
        setTitle();
    }
    return ret;
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

private void refresh(String state, String label) {

    // If Contextual Action Bar is open, don't refresh
    if (firstFragment != null && firstFragment.mActionMode != null) {
        return;/*from   w w  w .j  a v  a 2  s.  c om*/
    }

    if (qb_version.equals("2.x")) {
        qbQueryString = "json";
        params[0] = qbQueryString + "/events";
    }

    if (qb_version.equals("3.1.x")) {
        qbQueryString = "json";
        params[0] = qbQueryString + "/torrents";
    }

    if (qb_version.equals("3.2.x")) {
        qbQueryString = "query";
        params[0] = qbQueryString + "/torrents?filter=" + state;

        // Get API version in case it hasn't been gotten before
        if (qb_api == null || qb_api.equals("") || qb_api.equals("0")) {
            new qBittorrentApiTask().execute(new Intent());
        }

        // Label
        if (label != null && !label.equals(getResources().getString(R.string.drawer_label_all))) {

            if (label.equals(getResources().getString(R.string.drawer_label_unlabeled))) {
                label = "";
            }

            if (!labels.contains(label)) {
                label = getResources().getString(R.string.drawer_label_all);
            }

            saveLastLabel(label);

            //                Log.d("Debug", "Label filter: " + label);

            try {

                if (!label.equals(getResources().getString(R.string.drawer_label_all))) {

                    // I used a dummy URL to encode label
                    String labelEncoded = Uri.encode("http://www.dummy.org?label=" + label);

                    // then I got the the encoded label
                    labelEncoded = labelEncoded.substring(labelEncoded.indexOf("%3D") + 3);

                    // to build the url and pass it to params[0]
                    if (Integer.parseInt(MainActivity.qb_api) < 10) {
                        params[0] = params[0] + "&label=" + labelEncoded;
                    } else {
                        params[0] = params[0] + "&category=" + labelEncoded;
                    }
                }

            } catch (Exception e) {
                Log.d("Debug", "[Main] Label Exception: " + e.toString());
            }
        } else {
            //                Log.d("Debug", "Label filter2: " + label);

        }

    }

    params[1] = state;

    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    if (networkInfo != null && networkInfo.isConnected() && !networkInfo.isFailover()) {

        // Logs for reporting
        if (CustomLogger.isMainActivityReporting()) {
            generateSettingsReport();
        }

        if (hostname.equals("")) {
            qBittorrentNoSettingsFoundDialog(R.string.info, R.string.about_help1);
        } else {

            //                Log.d("Report", "Report: " + CustomLogger.getReport());

            if (qb_version.equals("3.2.x") && (cookie == null || cookie.equals(""))) {
                // Request new cookie and execute task in background

                if (connection403ErrorCounter > 1) {

                    toastText(R.string.error403);

                    httpStatusCode = 0;
                    disableRefreshSwipeLayout();
                } else {
                    new qBittorrentCookieTask().execute(params);
                }

            } else {

                if (connection403ErrorCounter > 1) {

                    if (cookie != null && !cookie.equals("")) {
                        // Only toasts the message if there is not a cookie set before
                        toastText(R.string.error403);

                        cookie = null;
                    }

                    httpStatusCode = 0;
                    disableRefreshSwipeLayout();
                } else {

                    // Execute the task in background
                    qbTask = new qBittorrentTask().execute(params);

                    // Check if  alternative speed limit is set
                    new qBittorrentCommand().execute(new String[] { "alternativeSpeedLimitsEnabled", "" });
                }
            }

        }

    } else {

        // Connection Error message
        toastText(R.string.connection_error);

        disableRefreshSwipeLayout();
    }

}

From source file:nl.mpcjanssen.simpletask.Simpletask.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Task t = getTaskAt(position);/*from   w  w  w. j a  v  a  2s. co  m*/
    final ArrayList<String> actions = new ArrayList<>();
    final ArrayList<String> links = new ArrayList<>();

    for (String link : t.getLinks()) {
        actions.add(ACTION_LINK);
        links.add(link);
    }

    for (String number : t.getPhoneNumbers()) {
        actions.add(ACTION_PHONE);
        links.add(number);
    }

    for (String mail : t.getMailAddresses()) {
        actions.add(ACTION_MAIL);
        links.add(mail);
    }

    final String[] linksArray = links.toArray(new String[0]);
    if (linksArray.length == 0) {
        getListView().setItemChecked(position, !getListView().isItemChecked(position));
    } else {
        AlertDialog.Builder build = new AlertDialog.Builder(this);
        build.setItems(linksArray, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent;
                String url = links.get(which);
                Log.v(TAG, "" + actions.get(which) + ": " + url);
                switch (actions.get(which)) {
                case ACTION_LINK:
                    if (url.startsWith("todo://")) {
                        File todoFolder = m_app.getTodoFile().getParentFile();
                        File newName = new File(todoFolder, url.substring(7));
                        m_app.switchTodoFile(newName);
                    } else {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        startActivity(intent);
                    }
                    break;
                case ACTION_PHONE:
                    String encodedNumber = Uri.encode(url);
                    intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + encodedNumber));
                    startActivity(intent);
                    break;
                case ACTION_MAIL:
                    intent = new Intent(Intent.ACTION_SEND, Uri.parse(url));
                    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { url });
                    intent.setType("text/plain");
                    startActivity(intent);

                }
            }
        });
        build.create().show();
    }
    return;
}

From source file:dk.nota.lyt.libvlc.PlaybackService.java

private synchronized void saveMediaList() {
    if (getCurrentMedia() == null)
        return;//from   w ww . j  a v  a 2s  .  c  om
    StringBuilder locations = new StringBuilder();
    boolean audio = true;
    for (int i = 0; i < mMediaList.size(); i++) {
        if (mMediaList.getMedia(i).getType() == MediaWrapper.TYPE_VIDEO)
            audio = false;
        locations.append(" ").append(Uri.encode(mMediaList.getMRL(i)));
    }
    //We save a concatenated String because putStringSet is APIv11.
    SharedPreferences.Editor editor = mSettings.edit();
    editor.putString(audio ? "audio_list" : "media_list", locations.toString().trim());
    editor.apply();
}

From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java

/**
 * Share all contacts that are currently selected. This method is pretty inefficient for
 * handling large numbers of contacts. I don't expect this to be a problem.
 *///  w w  w.  ja  v  a  2s .  c o  m
private void shareSelectedContacts() {
    final StringBuilder uriListBuilder = new StringBuilder();
    for (Long contactId : getSelectedContactIds()) {
        final Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId);
        final Uri lookupUri = ContactsContract.Contacts.getLookupUri(getContext().getContentResolver(),
                contactUri);
        if (lookupUri == null) {
            continue;
        }
        final List<String> pathSegments = lookupUri.getPathSegments();
        if (pathSegments.size() < 2) {
            continue;
        }
        final String lookupKey = pathSegments.get(pathSegments.size() - 2);
        if (uriListBuilder.length() > 0) {
            uriListBuilder.append(':');
        }
        uriListBuilder.append(Uri.encode(lookupKey));
    }
    if (uriListBuilder.length() == 0) {
        return;
    }
    final Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_MULTI_VCARD_URI,
            Uri.encode(uriListBuilder.toString()));
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(ContactsContract.Contacts.CONTENT_VCARD_TYPE);
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    try {
        startActivityForResult(Intent.createChooser(intent, getResources()
                .getQuantityString(R.plurals.title_share_via, /* quantity */ getSelectedContactIds().size())),
                ACTIVITY_REQUEST_CODE_SHARE);
    } catch (final ActivityNotFoundException ex) {
        Toast.makeText(getContext(), R.string.share_error, Toast.LENGTH_SHORT).show();
    }
}

From source file:io.github.mkjung.ivi.media.MediaDatabase.java

/**
 * Network favorites management/*from ww w  .  j  ava2  s.co m*/
 */

public synchronized void addNetworkFavItem(Uri uri, String title, String iconUrl) {
    ContentValues values = new ContentValues();
    values.put(NETWORK_FAV_URI, uri.toString());
    values.put(NETWORK_FAV_TITLE, Uri.encode(title));
    values.put(NETWORK_FAV_ICON_URL, Uri.encode(iconUrl));
    mDb.replace(NETWORK_FAV_TABLE_NAME, null, values);
}

From source file:com.piusvelte.sonet.core.SonetCreatePost.java

@Override
public void onClick(View v) {
    if (v == mSend) {
        if (!mAccountsService.isEmpty()) {
            final ProgressDialog loadingDialog = new ProgressDialog(this);
            final AsyncTask<Void, String, Void> asyncTask = new AsyncTask<Void, String, Void>() {
                @Override//from   w  w w  .ja  va2 s.  c om
                protected Void doInBackground(Void... arg0) {
                    Iterator<Map.Entry<Long, Integer>> entrySet = mAccountsService.entrySet().iterator();
                    while (entrySet.hasNext()) {
                        Map.Entry<Long, Integer> entry = entrySet.next();
                        final long accountId = entry.getKey();
                        final int service = entry.getValue();
                        final String placeId = mAccountsLocation.get(accountId);
                        // post or comment!
                        Cursor account = getContentResolver().query(
                                Accounts.getContentUri(SonetCreatePost.this),
                                new String[] { Accounts._ID, Accounts.TOKEN, Accounts.SECRET },
                                Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null);
                        if (account.moveToFirst()) {
                            final String serviceName = Sonet.getServiceName(getResources(), service);
                            publishProgress(serviceName);
                            String message;
                            SonetOAuth sonetOAuth;
                            HttpPost httpPost;
                            String response = null;
                            switch (service) {
                            case TWITTER:
                                sonetOAuth = new SonetOAuth(TWITTER_KEY, TWITTER_SECRET,
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.TOKEN))),
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.SECRET))));
                                // limit tweets to 140, breaking up the message if necessary
                                message = mMessage.getText().toString();
                                while (message.length() > 0) {
                                    final String send;
                                    if (message.length() > 140) {
                                        // need to break on a word
                                        int end = 0;
                                        int nextSpace = 0;
                                        for (int i = 0, i2 = message.length(); i < i2; i++) {
                                            end = nextSpace;
                                            if (message.substring(i, i + 1).equals(" ")) {
                                                nextSpace = i;
                                            }
                                        }
                                        // in case there are no spaces, just break on 140
                                        if (end == 0) {
                                            end = 140;
                                        }
                                        send = message.substring(0, end);
                                        message = message.substring(end + 1);
                                    } else {
                                        send = message;
                                        message = "";
                                    }
                                    httpPost = new HttpPost(String.format(TWITTER_UPDATE, TWITTER_BASE_URL));
                                    // resolve Error 417 Expectation by Twitter
                                    httpPost.getParams().setBooleanParameter("http.protocol.expect-continue",
                                            false);
                                    List<NameValuePair> params = new ArrayList<NameValuePair>();
                                    params.add(new BasicNameValuePair(Sstatus, send));
                                    if (placeId != null) {
                                        params.add(new BasicNameValuePair("place_id", placeId));
                                        params.add(new BasicNameValuePair("lat", mLat));
                                        params.add(new BasicNameValuePair("long", mLong));
                                    }
                                    try {
                                        httpPost.setEntity(new UrlEncodedFormEntity(params));
                                        response = SonetHttpClient.httpResponse(mHttpClient,
                                                sonetOAuth.getSignedRequest(httpPost));
                                    } catch (UnsupportedEncodingException e) {
                                        Log.e(TAG, e.toString());
                                    }
                                    publishProgress(serviceName,
                                            getString(response != null ? R.string.success : R.string.failure));
                                }
                                break;
                            case FACEBOOK:
                                // handle tags
                                StringBuilder tags = null;
                                if (mAccountsTags.containsKey(accountId)) {
                                    String[] accountTags = mAccountsTags.get(accountId);
                                    if ((accountTags != null) && (accountTags.length > 0)) {
                                        tags = new StringBuilder();
                                        tags.append("[");
                                        String tag_format;
                                        if (mPhotoPath != null)
                                            tag_format = "{\"tag_uid\":\"%s\",\"x\":0,\"y\":0}";
                                        else
                                            tag_format = "%s";
                                        for (int i = 0, l = accountTags.length; i < l; i++) {
                                            if (i > 0)
                                                tags.append(",");
                                            tags.append(String.format(tag_format, accountTags[i]));
                                        }
                                        tags.append("]");
                                    }
                                }
                                if (mPhotoPath != null) {
                                    // upload photo
                                    // uploading a photo takes a long time, have the service handle it
                                    Intent i = Sonet.getPackageIntent(
                                            SonetCreatePost.this.getApplicationContext(),
                                            PhotoUploadService.class);
                                    i.setAction(Sonet.ACTION_UPLOAD);
                                    i.putExtra(Accounts.TOKEN,
                                            account.getString(account.getColumnIndex(Accounts.TOKEN)));
                                    i.putExtra(Widgets.INSTANT_UPLOAD, mPhotoPath);
                                    i.putExtra(Statuses.MESSAGE, mMessage.getText().toString());
                                    i.putExtra(Splace, placeId);
                                    if (tags != null)
                                        i.putExtra(Stags, tags.toString());
                                    startService(i);
                                    publishProgress(serviceName + " photo");
                                } else {
                                    // regular post
                                    httpPost = new HttpPost(String.format(FACEBOOK_POST, FACEBOOK_BASE_URL,
                                            Saccess_token, mSonetCrypto.Decrypt(account
                                                    .getString(account.getColumnIndex(Accounts.TOKEN)))));
                                    List<NameValuePair> params = new ArrayList<NameValuePair>();
                                    params.add(new BasicNameValuePair(Smessage, mMessage.getText().toString()));
                                    if (placeId != null)
                                        params.add(new BasicNameValuePair(Splace, placeId));
                                    if (tags != null)
                                        params.add(new BasicNameValuePair(Stags, tags.toString()));
                                    try {
                                        httpPost.setEntity(new UrlEncodedFormEntity(params));
                                        response = SonetHttpClient.httpResponse(mHttpClient, httpPost);
                                    } catch (UnsupportedEncodingException e) {
                                        Log.e(TAG, e.toString());
                                    }
                                    publishProgress(serviceName,
                                            getString(response != null ? R.string.success : R.string.failure));
                                }
                                break;
                            case MYSPACE:
                                sonetOAuth = new SonetOAuth(MYSPACE_KEY, MYSPACE_SECRET,
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.TOKEN))),
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.SECRET))));
                                try {
                                    HttpPut httpPut = new HttpPut(
                                            String.format(MYSPACE_URL_STATUSMOOD, MYSPACE_BASE_URL));
                                    httpPut.setEntity(new StringEntity(String.format(MYSPACE_STATUSMOOD_BODY,
                                            mMessage.getText().toString())));
                                    response = SonetHttpClient.httpResponse(mHttpClient,
                                            sonetOAuth.getSignedRequest(httpPut));
                                } catch (IOException e) {
                                    Log.e(TAG, e.toString());
                                }
                                // warn users about myspace permissions
                                if (response != null) {
                                    publishProgress(serviceName, getString(R.string.success));
                                } else {
                                    publishProgress(serviceName, getString(R.string.failure) + " "
                                            + getString(R.string.myspace_permissions_message));
                                }
                                break;
                            case FOURSQUARE:
                                try {
                                    message = URLEncoder.encode(mMessage.getText().toString(), "UTF-8");
                                    if (placeId != null) {
                                        if (message != null) {
                                            httpPost = new HttpPost(String.format(FOURSQUARE_CHECKIN,
                                                    FOURSQUARE_BASE_URL, placeId, message, mLat, mLong,
                                                    mSonetCrypto.Decrypt(account.getString(
                                                            account.getColumnIndex(Accounts.TOKEN)))));
                                        } else {
                                            httpPost = new HttpPost(String.format(FOURSQUARE_CHECKIN_NO_SHOUT,
                                                    FOURSQUARE_BASE_URL, placeId, mLat, mLong,
                                                    mSonetCrypto.Decrypt(account.getString(
                                                            account.getColumnIndex(Accounts.TOKEN)))));
                                        }
                                    } else {
                                        httpPost = new HttpPost(String.format(FOURSQUARE_CHECKIN_NO_VENUE,
                                                FOURSQUARE_BASE_URL, message, mSonetCrypto.Decrypt(account
                                                        .getString(account.getColumnIndex(Accounts.TOKEN)))));
                                    }
                                    response = SonetHttpClient.httpResponse(mHttpClient, httpPost);
                                } catch (UnsupportedEncodingException e) {
                                    Log.e(TAG, e.toString());
                                }
                                publishProgress(serviceName,
                                        getString(response != null ? R.string.success : R.string.failure));
                                break;
                            case LINKEDIN:
                                sonetOAuth = new SonetOAuth(LINKEDIN_KEY, LINKEDIN_SECRET,
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.TOKEN))),
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.SECRET))));
                                try {
                                    httpPost = new HttpPost(String.format(LINKEDIN_POST, LINKEDIN_BASE_URL));
                                    httpPost.setEntity(new StringEntity(String.format(LINKEDIN_POST_BODY, "",
                                            mMessage.getText().toString())));
                                    httpPost.addHeader(new BasicHeader("Content-Type", "application/xml"));
                                    response = SonetHttpClient.httpResponse(mHttpClient,
                                            sonetOAuth.getSignedRequest(httpPost));
                                } catch (IOException e) {
                                    Log.e(TAG, e.toString());
                                }
                                publishProgress(serviceName,
                                        getString(response != null ? R.string.success : R.string.failure));
                                break;
                            case IDENTICA:
                                sonetOAuth = new SonetOAuth(IDENTICA_KEY, IDENTICA_SECRET,
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.TOKEN))),
                                        mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.SECRET))));
                                // limit tweets to 140, breaking up the message if necessary
                                message = mMessage.getText().toString();
                                while (message.length() > 0) {
                                    final String send;
                                    if (message.length() > 140) {
                                        // need to break on a word
                                        int end = 0;
                                        int nextSpace = 0;
                                        for (int i = 0, i2 = message.length(); i < i2; i++) {
                                            end = nextSpace;
                                            if (message.substring(i, i + 1).equals(" ")) {
                                                nextSpace = i;
                                            }
                                        }
                                        // in case there are no spaces, just break on 140
                                        if (end == 0) {
                                            end = 140;
                                        }
                                        send = message.substring(0, end);
                                        message = message.substring(end + 1);
                                    } else {
                                        send = message;
                                        message = "";
                                    }
                                    httpPost = new HttpPost(String.format(IDENTICA_UPDATE, IDENTICA_BASE_URL));
                                    // resolve Error 417 Expectation by Twitter
                                    httpPost.getParams().setBooleanParameter("http.protocol.expect-continue",
                                            false);
                                    List<NameValuePair> params = new ArrayList<NameValuePair>();
                                    params.add(new BasicNameValuePair(Sstatus, send));
                                    if (placeId != null) {
                                        params.add(new BasicNameValuePair("place_id", placeId));
                                        params.add(new BasicNameValuePair("lat", mLat));
                                        params.add(new BasicNameValuePair("long", mLong));
                                    }
                                    try {
                                        httpPost.setEntity(new UrlEncodedFormEntity(params));
                                        response = SonetHttpClient.httpResponse(mHttpClient,
                                                sonetOAuth.getSignedRequest(httpPost));
                                    } catch (UnsupportedEncodingException e) {
                                        Log.e(TAG, e.toString());
                                    }
                                    publishProgress(serviceName,
                                            getString(response != null ? R.string.success : R.string.failure));
                                }
                                break;
                            case CHATTER:
                                // need to get an updated access_token
                                response = SonetHttpClient.httpResponse(mHttpClient, new HttpPost(
                                        String.format(CHATTER_URL_ACCESS, CHATTER_KEY, mSonetCrypto.Decrypt(
                                                account.getString(account.getColumnIndex(Accounts.TOKEN))))));
                                if (response != null) {
                                    try {
                                        JSONObject jobj = new JSONObject(response);
                                        if (jobj.has("instance_url") && jobj.has(Saccess_token)) {
                                            httpPost = new HttpPost(String.format(CHATTER_URL_POST,
                                                    jobj.getString("instance_url"),
                                                    Uri.encode(mMessage.getText().toString())));
                                            httpPost.setHeader("Authorization",
                                                    "OAuth " + jobj.getString(Saccess_token));
                                            response = SonetHttpClient.httpResponse(mHttpClient, httpPost);
                                        }
                                    } catch (JSONException e) {
                                        Log.e(TAG, serviceName + ":" + e.toString());
                                        Log.e(TAG, response);
                                    }
                                }
                                publishProgress(serviceName,
                                        getString(response != null ? R.string.success : R.string.failure));
                                break;
                            }
                        }
                        account.close();
                    }
                    return null;
                }

                @Override
                protected void onProgressUpdate(String... params) {
                    if (params.length == 1) {
                        loadingDialog.setMessage(String.format(getString(R.string.sending), params[0]));
                    } else {
                        (Toast.makeText(SonetCreatePost.this, params[0] + " " + params[1], Toast.LENGTH_LONG))
                                .show();
                    }
                }

                @Override
                protected void onPostExecute(Void result) {
                    if (loadingDialog.isShowing())
                        loadingDialog.dismiss();
                    finish();
                }

            };
            loadingDialog.setMessage(getString(R.string.loading));
            loadingDialog.setCancelable(true);
            loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    if (!asyncTask.isCancelled())
                        asyncTask.cancel(true);
                }
            });
            loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    });
            loadingDialog.show();
            asyncTask.execute();
        } else
            (Toast.makeText(SonetCreatePost.this, "no accounts selected", Toast.LENGTH_LONG)).show();
    }
}