Example usage for android.provider BaseColumns _ID

List of usage examples for android.provider BaseColumns _ID

Introduction

In this page you can find the example usage for android.provider BaseColumns _ID.

Prototype

String _ID

To view the source code for android.provider BaseColumns _ID.

Click Source Link

Document

The unique ID for a row.

Usage

From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // Dialog doesn't allow us to wait for a result, so we need to store
    // the info we need for when the dialog posts its result
    mQueryCursor.moveToPosition(position);
    if (mQueryCursor.isBeforeFirst() || mQueryCursor.isAfterLast()) {
        return;/*from w w  w .  j ava2  s .c o  m*/
    }
    String selectedType = mQueryCursor.getString(mQueryCursor.getColumnIndexOrThrow(Audio.Media.MIME_TYPE));

    if ("artist".equals(selectedType)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);

        TextView tv1 = (TextView) v.findViewById(R.id.listview_item_line_one);
        String artistName = tv1.getText().toString();

        Bundle bundle = new Bundle();
        bundle.putString(MIME_TYPE, Audio.Artists.CONTENT_TYPE);
        bundle.putString(ARTIST_KEY, artistName);
        bundle.putLong(BaseColumns._ID, id);

        intent.setClass(this, TracksBrowser.class);
        intent.putExtras(bundle);
        startActivity(intent);
        finish();
    } else if ("album".equals(selectedType)) {
        TextView tv1 = (TextView) v.findViewById(R.id.listview_item_line_one);
        TextView tv2 = (TextView) v.findViewById(R.id.listview_item_line_two);

        String artistName = tv2.getText().toString();
        String albumName = tv1.getText().toString();

        Bundle bundle = new Bundle();
        bundle.putString(MIME_TYPE, Audio.Albums.CONTENT_TYPE);
        bundle.putString(ARTIST_KEY, artistName);
        bundle.putString(ALBUM_KEY, albumName);
        bundle.putLong(BaseColumns._ID, id);

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(this, TracksBrowser.class);
        intent.putExtras(bundle);
        startActivity(intent);
        finish();
    } else if (position >= 0 && id >= 0) {
        long[] list = new long[] { id };
        MusicUtils.playAll(this, list, 0);
    } else {
        Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id);
    }
}

From source file:org.catnut.fragment.ConversationFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    int limit = args.getInt(TAG, getFetchSize());
    return CatnutUtils.getCursorLoader(getActivity(), CatnutProvider.parse(Comment.MULTIPLE), PROJECTION, null,
            null, Comment.TABLE + " as c", "inner join " + User.TABLE + " as u on c.uid=u._id",
            "c." + BaseColumns._ID + " desc", String.valueOf(limit));
}

From source file:fr.openbike.android.database.OpenBikeDBAdapter.java

public boolean insertNetwork(Network network) throws SQLiteException {
    if (network == null)
        return false;
    if (getNetwork(network.getId(), new String[] { BaseColumns._ID }) != null) {
        return false;
    }/*from w  w w .  j av a2 s  .c  o  m*/
    ContentValues newValues = new ContentValues();
    newValues.put(BaseColumns._ID, network.getId());
    newValues.put(KEY_NAME, network.getName());
    newValues.put(KEY_CITY, network.getCity());
    newValues.put(KEY_SERVER, network.getServerUrl());
    newValues.put(KEY_LONGITUDE, network.getLongitude());
    newValues.put(KEY_LATITUDE, network.getLatitude());
    newValues.put(KEY_SPECIAL_NAME, network.getSpecialName());
    newValues.put(KEY_VERSION, 0);
    mDb.insertOrThrow(NETWORKS_TABLE, null, newValues);
    return true;
}

From source file:org.awesomeapp.messenger.ui.AccountViewFragment.java

private void initFragment() {

    Intent i = getIntent();// w  w w . j  a v a 2 s.c o m

    mApp = (ImApp) getActivity().getApplication();

    String action = i.getAction();

    if (i.hasExtra("isSignedIn"))
        isSignedIn = i.getBooleanExtra("isSignedIn", false);

    final ProviderDef provider;

    mSignInHelper = new SignInHelper(getActivity(), new SimpleAlertHandler(getActivity()));
    SignInHelper.SignInListener signInListener = new SignInHelper.SignInListener() {
        @Override
        public void connectedToService() {
        }

        @Override
        public void stateChanged(int state, long accountId) {
            if (state == ImConnection.LOGGED_IN) {
                //  mSignInHelper.goToAccount(accountId);
                // finish();
                isSignedIn = true;
            } else {
                isSignedIn = false;
            }

        }
    };

    mSignInHelper.setSignInListener(signInListener);

    ContentResolver cr = getActivity().getContentResolver();

    Uri uri = i.getData();
    // check if there is account information and direct accordingly
    if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
        if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {
            action = Intent.ACTION_INSERT;
        } else {
            action = Intent.ACTION_EDIT;
        }
    }

    if (Intent.ACTION_INSERT.equals(action) && uri.getScheme().equals("ima")) {
        ImPluginHelper helper = ImPluginHelper.getInstance(getActivity());
        String authority = uri.getAuthority();
        String[] userpass_host = authority.split("@");
        String[] user_pass = userpass_host[0].split(":");
        mUserName = user_pass[0].toLowerCase(Locale.getDefault());
        String pass = user_pass[1];
        mDomain = userpass_host[1].toLowerCase(Locale.getDefault());
        mPort = 0;
        final boolean regWithTor = i.getBooleanExtra("useTor", false);

        Cursor cursor = openAccountByUsernameAndDomain(cr);
        boolean exists = cursor.moveToFirst();
        long accountId;
        if (exists) {
            accountId = cursor.getLong(0);
            mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
            pass = cursor.getString(ACCOUNT_PASSWORD_COLUMN);

            setAccountKeepSignedIn(true);
            mSignInHelper.activateAccount(mProviderId, accountId);
            mSignInHelper.signIn(pass, mProviderId, accountId, true);
            //  setResult(RESULT_OK);
            cursor.close();
            // finish();
            return;

        } else {
            mProviderId = helper.createAdditionalProvider(helper.getProviderNames().get(0)); //xmpp FIXME
            accountId = ImApp.insertOrUpdateAccount(cr, mProviderId, -1, mUserName, mUserName, pass);
            mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
            mSignInHelper.activateAccount(mProviderId, accountId);
            createNewAccount(mUserName, pass, accountId, regWithTor);
            cursor.close();
            return;
        }

    } else if (Intent.ACTION_INSERT.equals(action)) {

        mOriginalUserAccount = "";
        // TODO once we implement multiple IM protocols
        mProviderId = ContentUris.parseId(uri);
        provider = mApp.getProvider(mProviderId);

    } else if (Intent.ACTION_EDIT.equals(action)) {

        if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {
            LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity>Bad data");
            return;
        }

        isEdit = true;

        Cursor cursor = cr.query(uri, ACCOUNT_PROJECTION, null, null, null);

        if (cursor == null) {

            return;
        }

        if (!cursor.moveToFirst()) {
            cursor.close();

            return;
        }

        mAccountId = cursor.getLong(cursor.getColumnIndexOrThrow(BaseColumns._ID));

        mProviderId = cursor.getLong(ACCOUNT_PROVIDER_COLUMN);
        provider = mApp.getProvider(mProviderId);

        Cursor pCursor = cr.query(Imps.ProviderSettings.CONTENT_URI,
                new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE },
                Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(mProviderId) }, null);

        Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, cr, mProviderId,
                false /* don't keep updated */, null /* no handler */);

        try {
            mOriginalUserAccount = cursor.getString(ACCOUNT_USERNAME_COLUMN) + "@" + settings.getDomain();
            mEditUserAccount.setText(mOriginalUserAccount);
            mEditPass.setText(cursor.getString(ACCOUNT_PASSWORD_COLUMN));
            //mRememberPass.setChecked(!cursor.isNull(ACCOUNT_PASSWORD_COLUMN));
            //mUseTor.setChecked(settings.getUseTor());
            mBtnQrDisplay.setVisibility(View.VISIBLE);
        } finally {
            settings.close();
            cursor.close();
        }

    } else {
        LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity> unknown intent action " + action);
        return;
    }

    setupUIPost();

}

From source file:com.coinomi.wallet.ExchangeRatesProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    final long now = System.currentTimeMillis();

    final List<String> pathSegments = uri.getPathSegments();
    if (pathSegments.size() != 2) {
        throw new IllegalArgumentException("Unrecognized URI: " + uri);
    }/*  www. ja  v a 2  s  . com*/

    final boolean offline = uri.getQueryParameter(QUERY_PARAM_OFFLINE) != null;
    long lastUpdated;

    final String symbol;
    final boolean isLocalToCrypto;

    if (pathSegments.get(0).equals("to-crypto")) {
        isLocalToCrypto = true;
        symbol = pathSegments.get(1);
        lastUpdated = symbol.equals(lastLocalCurrency) ? localToCryptoLastUpdated : 0;
    } else if (pathSegments.get(0).equals("to-local")) {
        isLocalToCrypto = false;
        symbol = pathSegments.get(1);
        lastUpdated = symbol.equals(lastCryptoCurrency) ? cryptoToLocalLastUpdated : 0;
    } else {
        throw new IllegalArgumentException("Unrecognized URI path: " + uri);
    }

    if (!offline && (lastUpdated == 0 || now - lastUpdated > Constants.RATE_UPDATE_FREQ_MS)) {
        URL url;
        try {
            if (isLocalToCrypto) {
                url = new URL(String.format(TO_CRYPTO_URL, symbol));
            } else {
                url = new URL(String.format(TO_LOCAL_URL, symbol));
            }
        } catch (final MalformedURLException x) {
            throw new RuntimeException(x); // Should not happen
        }

        JSONObject newExchangeRatesJson = requestExchangeRatesJson(url);
        Map<String, ExchangeRate> newExchangeRates = parseExchangeRates(newExchangeRatesJson, symbol,
                isLocalToCrypto);

        if (newExchangeRates != null) {
            if (isLocalToCrypto) {
                localToCryptoRates = newExchangeRates;
                localToCryptoLastUpdated = now;
                lastLocalCurrency = symbol;
                config.setCachedExchangeRates(lastLocalCurrency, newExchangeRatesJson);
            } else {
                cryptoToLocalRates = newExchangeRates;
                cryptoToLocalLastUpdated = now;
                lastCryptoCurrency = symbol;
            }
        }
    }

    Map<String, ExchangeRate> exchangeRates = isLocalToCrypto ? localToCryptoRates : cryptoToLocalRates;

    if (exchangeRates == null)
        return null;

    final MatrixCursor cursor = new MatrixCursor(new String[] { BaseColumns._ID, KEY_CURRENCY_ID, KEY_RATE_COIN,
            KEY_RATE_COIN_CODE, KEY_RATE_FIAT, KEY_RATE_FIAT_CODE, KEY_SOURCE });

    if (selection == null) {
        for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) {
            final ExchangeRate exchangeRate = entry.getValue();
            addRow(cursor, exchangeRate);
        }
    } else if (selection.equals(KEY_CURRENCY_ID)) {
        final ExchangeRate exchangeRate = exchangeRates.get(selectionArgs[0]);
        if (exchangeRate != null) {
            addRow(cursor, exchangeRate);
        }
    }

    return cursor;
}

From source file:com.pawnua.android.app.gpstrips.activities.TripDetailActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();/*from www . j  a v  a  2s. c o m*/
        return true;

    case R.id.action_startStopService: {
        if (isServiceStarted) {
            LocationServiceManager.stopLocationService(this, trip);
            isServiceStarted = !isServiceStarted;
            setMenuVisible();
        } else {
            LocationServiceManager.startLocationService(this, trip);
            isServiceStarted = !isServiceStarted;
            setMenuVisible();
        }

        return true;
    }

    case R.id.action_startService: {
        LocationServiceManager.startLocationService(this, trip);
        setMenuVisible();
        return true;
    }
    case R.id.action_stopService: {
        LocationServiceManager.stopLocationService(this, trip);
        setMenuVisible();
        return true;
    }

    case R.id.action_showLocationList: {
        Intent intent = new Intent(this, TripLocationListActivity.class);
        intent.putExtra(BaseColumns._ID, trip.getId());

        startActivity(intent);
        return true;
    }

    case R.id.action_openMap: {
        openMap();
        return true;
    }

    case R.id.action_about: {
        new AboutFragment().show(mFragmentManager, "about_layout");
        return true;
    }

    case R.id.action_export: {

        saveTripTask(trip);
        return true;
    }

    case R.id.action_exportDisk: {

        Intent intent = new Intent(this, DiskCreateFileActivity.class);
        intent.putExtra(BaseColumns._ID, trip.getId());

        startActivity(intent);

        return true;
    }

    case R.id.action_show_camera: {

        takePhoto();
        return true;
    }

    case R.id.action_show_gallery: {

        openThumbGallery();
        return true;
    }

    case R.id.action_show_gallery_vp: {

        // open Gallery
        GalleryDataManager.openGallery(this, trip, "");

        return true;
    }

    case R.id.action_share: {

        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, trip.getName());
        sendIntent.setType("message/rfc822");
        //                sendIntent.setType("text/plain");

        Intent openInChooser = Intent.createChooser(sendIntent, "");

        startActivity(openInChooser);

        return true;
    }

    }
    return super.onOptionsItemSelected(item);
}

From source file:com.mygeopay.wallet.ExchangeRatesProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    final long now = System.currentTimeMillis();

    final List<String> pathSegments = uri.getPathSegments();
    if (pathSegments.size() != 2) {
        throw new IllegalArgumentException("Unrecognized URI: " + uri);
    }//from w ww. jav a  2 s .c  o m

    final boolean offline = uri.getQueryParameter(QUERY_PARAM_OFFLINE) != null;
    long lastUpdated;
    // TODO Add rate values for other Altcoins
    final String symbol;
    final boolean isLocalToCrypto;

    if (pathSegments.get(0).equals("to-crypto")) {
        isLocalToCrypto = true;
        symbol = pathSegments.get(1);
        lastUpdated = symbol.equals(lastLocalCurrency) ? localToCryptoLastUpdated : 0;
    } else if (pathSegments.get(0).equals("to-local")) {
        isLocalToCrypto = false;
        symbol = pathSegments.get(1);
        lastUpdated = symbol.equals(lastCryptoCurrency) ? cryptoToLocalLastUpdated : 0;
    } else {
        throw new IllegalArgumentException("Unrecognized URI path: " + uri);
    }
    // TODO Add rate values for other Altcoins
    if (!offline && (lastUpdated == 0 || now - lastUpdated > Constants.RATE_UPDATE_FREQ_MS)) {
        URL url;
        try {
            if (isLocalToCrypto) {
                url = new URL(String.format(TO_CRYPTO_URL, symbol));
            } else {
                url = new URL(String.format(TO_LOCAL_URL, symbol));
            }
        } catch (final MalformedURLException x) {
            throw new RuntimeException(x); // Should not happen
        }

        JSONObject newExchangeRatesJson = requestExchangeRatesJson(url);
        Map<String, ExchangeRate> newExchangeRates = parseExchangeRates(newExchangeRatesJson, symbol,
                isLocalToCrypto);

        if (newExchangeRates != null) {
            if (isLocalToCrypto) {
                localToCryptoRates = newExchangeRates;
                localToCryptoLastUpdated = now;
                lastLocalCurrency = symbol;
                config.setCachedExchangeRates(lastLocalCurrency, newExchangeRatesJson);
            } else {
                cryptoToLocalRates = newExchangeRates;
                cryptoToLocalLastUpdated = now;
                lastCryptoCurrency = symbol;
            }
        }
    }

    Map<String, ExchangeRate> exchangeRates = isLocalToCrypto ? localToCryptoRates : cryptoToLocalRates;

    if (exchangeRates == null)
        return null;

    final MatrixCursor cursor = new MatrixCursor(new String[] { BaseColumns._ID, KEY_CURRENCY_ID, KEY_RATE_COIN,
            KEY_RATE_COIN_CODE, KEY_RATE_FIAT, KEY_RATE_FIAT_CODE, KEY_SOURCE });

    if (selection == null) {
        for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) {
            final ExchangeRate exchangeRate = entry.getValue();
            addRow(cursor, exchangeRate);
        }
    } else if (selection.equals(KEY_CURRENCY_ID)) {
        final ExchangeRate exchangeRate = exchangeRates.get(selectionArgs[0]);
        if (exchangeRate != null) {
            addRow(cursor, exchangeRate);
        }
    }

    return cursor;
}

From source file:org.opensilk.music.library.folders.provider.FoldersLibraryProvider.java

public static List<Track> convertAudioFilesToTracks(Context context, File base, List<File> audioFiles) {
    if (audioFiles.size() == 0) {
        return Collections.emptyList();
    }//from w ww  .j  a v a 2s  .  co m

    final List<Track> trackList = new ArrayList<>(audioFiles.size());

    Cursor c = null;
    Cursor c2 = null;
    try {
        final HashMap<String, File> pathMap = new HashMap<>();

        //Build the selection
        final int size = audioFiles.size();
        final StringBuilder selection = new StringBuilder();
        selection.append(MediaStore.Audio.AudioColumns.DATA + " IN (");
        for (int i = 0; i < size; i++) {
            final File f = audioFiles.get(i);
            final String path = f.getAbsolutePath();
            pathMap.put(path, f); //Add file to map while where iterating
            selection.append("'").append(StringUtils.replace(path, "'", "''")).append("'");
            if (i < size - 1) {
                selection.append(",");
            }
        }
        selection.append(")");

        //make query
        c = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, SONG_PROJECTION,
                selection.toString(), null, null);
        if (c != null && c.moveToFirst()) {
            //track albums for second query
            final HashMap<Long, List<Track.Builder>> albumsMap = new HashMap<>();
            do {
                final File f = pathMap
                        .remove(c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DATA)));
                if (f != null) {
                    Track.Builder tb = Track.builder().setIdentity(toRelativePath(base, f))
                            .setName(c.getString(
                                    c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DISPLAY_NAME)))
                            .setArtistName(
                                    c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.ARTIST)))
                            .setAlbumName(
                                    c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.ALBUM)))
                            .setAlbumIdentity(c
                                    .getString(c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.ALBUM_ID)))
                            .setDuration(
                                    c.getInt(c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DURATION))
                                            / 1000)
                            .setMimeType(c.getString(
                                    c.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.MIME_TYPE)))
                            .setDataUri(ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                                    c.getLong(c.getColumnIndexOrThrow(BaseColumns._ID))))
                            .setArtworkUri(ContentUris.withAppendedId(BASE_ARTWORK_URI,
                                    c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID))));
                    long albumId = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID));
                    List<Track.Builder> tsForAlbum = albumsMap.get(albumId);
                    if (tsForAlbum == null) {
                        tsForAlbum = new ArrayList<>();
                        albumsMap.put(albumId, tsForAlbum);
                    }
                    tsForAlbum.add(tb);
                }
            } while (c.moveToNext());

            //Get the albumartists
            final Set<Long> albumIds = albumsMap.keySet();
            final int size2 = albumIds.size();
            final StringBuilder selection2 = new StringBuilder();
            selection2.append(BaseColumns._ID + " IN (");
            int i = 0;
            for (long id : albumIds) {
                selection2.append(id);
                if (++i < size2) {
                    selection2.append(",");
                }
            }
            selection2.append(")");
            c2 = context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
                    SONG_ALBUM_PROJECTION, selection2.toString(), null, null);
            if (c2 != null && c2.moveToFirst()) {
                do {
                    final long id = c2.getLong(0);
                    final String artist = c2.getString(1);
                    List<Track.Builder> albumTracks = albumsMap.remove(id);
                    if (albumTracks != null) {
                        for (Track.Builder tb : albumTracks) {
                            tb.setAlbumArtistName(artist);
                            trackList.add(tb.build());
                        }
                    }
                } while (c2.moveToNext());
            }
            if (!albumsMap.isEmpty()) {
                Timber.w("%d albums didn't make the cursor", albumsMap.size());
                for (List<Track.Builder> tbs : albumsMap.values()) {
                    for (Track.Builder tb : tbs) {
                        trackList.add(tb.build());
                    }
                }
            }
        }
        if (!pathMap.isEmpty()) {
            Timber.w("%d audioFiles didn't make the cursor", pathMap.size());
            for (File f : pathMap.values()) {
                Track t = Track.builder().setIdentity(toRelativePath(base, f)).setName(f.getName())
                        .setMimeType(guessMimeType(f)).setDataUri(Uri.fromFile(f)).build();
                trackList.add(t);
            }
        }
    } catch (Exception e) {
        if (DUMPSTACKS)
            Timber.e(e, "convertAudioFilesToTracks");
    } finally {
        closeQuietly(c);
        closeQuietly(c2);
    }
    return trackList;
}

From source file:ru.valle.safetrade.BuyActivity.java

private void loadState(final long id) {
    cancelAllTasks();/*from w  ww  .  jav  a  2 s  .  co  m*/
    loadStateTask = new AsyncTask<Void, Void, TradeRecord>() {
        @Override
        protected TradeRecord doInBackground(Void... params) {
            SQLiteDatabase db = DatabaseHelper.getInstance(BuyActivity.this).getReadableDatabase();
            Cursor cursor = db.query(DatabaseHelper.TABLE_HISTORY, null, BaseColumns._ID + "=?",
                    new String[] { String.valueOf(id) }, null, null, null);
            ArrayList<TradeRecord> tradeRecords = DatabaseHelper.readTradeRecords(cursor);
            return tradeRecords.isEmpty() ? null : tradeRecords.get(0);
        }

        @Override
        protected void onPostExecute(TradeRecord tradeRecord) {
            tradeInfo = tradeRecord;
            loadStateTask = null;
            rowId = tradeRecord.id;
            encryptedPrivateKeyView.setText(tradeRecord.encryptedPrivateKey);
            addressView.setText(tradeRecord.address);
            confirmationCodeView.setText(tradeRecord.confirmationCode);
            intermediateCodeView.setText(tradeRecord.intermediateCode);
            MainActivity.updateBalance(BuyActivity.this, id, tradeInfo.address, new Listener<AddressState>() {
                @Override
                public void onSuccess(AddressState result) {
                    if (result != null) {
                        balanceView.setText(BTCUtils.formatValue(result.getBalance()) + " BTC");
                    }
                }
            });
        }
    };
    if (Build.VERSION.SDK_INT >= 11) {
        loadStateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        loadStateTask.execute();
    }
}

From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java

private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
    if (filter == null) {
        filter = "";
    }/*www  .j  a v a2 s. co m*/
    String[] ccols = new String[] { BaseColumns._ID, Audio.Media.MIME_TYPE, Audio.Artists.ARTIST,
            Audio.Albums.ALBUM, Audio.Media.TITLE, "data1", "data2" };

    Uri search = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(filter));

    Cursor ret = null;
    if (async != null) {
        async.startQuery(0, null, search, ccols, null, null, null);
    } else {
        ret = MusicUtils.query(this, search, ccols, null, null, null);
    }
    return ret;
}