Example usage for android.net Uri withAppendedPath

List of usage examples for android.net Uri withAppendedPath

Introduction

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

Prototype

public static Uri withAppendedPath(Uri baseUri, String pathSegment) 

Source Link

Document

Creates a new Uri by appending an already-encoded path segment to a base Uri.

Usage

From source file:cz.maresmar.sfm.view.order.OrderFragment.java

private void deleteOrder(long orderId) {
    AsyncTask.execute(() -> {/*from   ww w.  j a  va 2 s.  c om*/
        Uri orderUri = ContentUris.withAppendedId(Uri.withAppendedPath(mUserUri, ProviderContract.ACTION_PATH),
                orderId);

        int deletedRows = getContext().getContentResolver().delete(orderUri, null, null);
        if (BuildConfig.DEBUG) {
            Assert.isOne(deletedRows);
        }
    });
}

From source file:au.com.cybersearch2.classyfy.MainActivity.java

/**
 * Display content - Heading and list of top categories
 * @param nodeDetails Bean containing details to be displayed
 *///from w  w  w.ja  v  a2  s  . c o  m
protected void displayContent(NodeDetailsBean nodeDetails) {
    View categoryDetails = ViewHelper.createRecordView(this, nodeDetails.getHeading(),
            nodeDetails.getCategoryTitles(), true, new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Intent viewIntent = new Intent(MainActivity.this, TitleSearchResultsActivity.class);
                    viewIntent.setData(
                            Uri.withAppendedPath(ClassyFySearchEngine.CONTENT_URI, String.valueOf(id)));
                    viewIntent.setAction(Intent.ACTION_VIEW);
                    startActivity(viewIntent);
                    finish();
                }
            });
    LinearLayout categoryLayout = (LinearLayout) findViewById(R.id.top_category);
    categoryLayout.addView(categoryDetails);
}

From source file:org.getlantern.firetweet.adapter.UserHashtagAutoCompleteAdapter.java

@Override
public Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
    char token = mToken;
    if (mEditText != null && constraint != null) {
        final CharSequence text = mEditText.getText();
        token = text.charAt(mEditText.getSelectionEnd() - constraint.length() - 1);
    }/*from  w  w  w  .  ja  v  a2  s . c  o m*/
    if (isAtSymbol(token) == isAtSymbol(mToken)) {
        final FilterQueryProvider filter = getFilterQueryProvider();
        if (filter != null)
            return filter.runQuery(constraint);
    }
    mToken = token;
    final String constraintEscaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null;
    if (isAtSymbol(token)) {
        final Expression selection;
        final String[] selectionArgs;
        if (constraintEscaped != null) {
            final long[] nicknameIds = Utils.getMatchedNicknameIds(ParseUtils.parseString(constraint),
                    mUserNicknamePreferences);
            selection = Expression.or(Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"),
                    Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"),
                    Expression.in(new Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds)));
            selectionArgs = new String[] { constraintEscaped, constraintEscaped };
        } else {
            selection = null;
            selectionArgs = null;
        }
        final OrderBy orderBy = new OrderBy(
                new String[] { CachedUsers.LAST_SEEN, "score", CachedUsers.SCREEN_NAME, CachedUsers.NAME },
                new boolean[] { false, false, true, true });
        final Cursor cursor = mResolver.query(
                Uri.withAppendedPath(CachedUsers.CONTENT_URI_WITH_SCORE, String.valueOf(mAccountId)),
                CachedUsers.BASIC_COLUMNS, selection != null ? selection.getSQL() : null, selectionArgs,
                orderBy.getSQL());
        if (Utils.isDebugBuild() && cursor == null)
            throw new NullPointerException();
        return cursor;
    } else {
        final String selection = constraintEscaped != null ? CachedHashtags.NAME + " LIKE ?||'%' ESCAPE '^'"
                : null;
        final String[] selectionArgs = constraintEscaped != null ? new String[] { constraintEscaped } : null;
        final Cursor cursor = mDatabase.query(true, CachedHashtags.TABLE_NAME, CachedHashtags.COLUMNS,
                selection, selectionArgs, null, null, CachedHashtags.NAME, null);
        if (Utils.isDebugBuild() && cursor == null)
            throw new NullPointerException();
        return cursor;
    }
}

From source file:com.fede.Utilities.GeneralUtils.java

public static String[] getContactNumbers(String contact, Context c) throws NameNotFoundException {
    // Find a contact using a partial name match
    Uri lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, contact);
    Cursor idCursor = c.getContentResolver().query(lookupUri, null, null, null, null);
    String id = null;//from   w  w  w . ja va  2  s .c om
    if (idCursor.moveToFirst()) { // I try with the first record
        int idIdx = idCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID);
        id = idCursor.getString(idIdx);

    }
    idCursor.close();

    if (id == null)
        throw new NameNotFoundException(c.getString(R.string.name_not_found));

    // Return all the contact details of type PHONE for the contact we found

    String where = ContactsContract.Data.CONTACT_ID + " = " + id + " AND " + ContactsContract.Data.MIMETYPE
            + " = '" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "'";

    Cursor dataCursor = c.getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, where, null,
            null);
    // Use the convenience properties to get the index of the columns
    int nameIdx = dataCursor.getColumnIndexOrThrow(ContactsContract.Data.DISPLAY_NAME);
    int phoneIdx = dataCursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER);

    String[] result = new String[dataCursor.getCount()];

    if (dataCursor.getCount() == 0)
        throw new NameNotFoundException(c.getString(R.string.name_not_valid_numbers));

    if (dataCursor.moveToFirst())
        do {
            // Extract the name.
            String name = dataCursor.getString(nameIdx);
            // Extract the phone number.
            String number = dataCursor.getString(phoneIdx);
            int position = dataCursor.getPosition();
            if (position == 0) // I put the name only in the first record to save space
                result[position] = name + " (" + number + ")";
            else
                result[position] = " (" + number + ")";

        } while (dataCursor.moveToNext());
    dataCursor.close();
    return result;

}

From source file:org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter.java

@Override
public Cursor runQueryOnBackgroundThread(final CharSequence constraint) {
    char token = mToken;
    if (mEditText != null && constraint != null) {
        final CharSequence text = mEditText.getText();
        token = text.charAt(mEditText.getSelectionEnd() - constraint.length() - 1);
    }// w  w  w.java 2  s. c o m
    if (isAtSymbol(token) == isAtSymbol(mToken)) {
        final FilterQueryProvider filter = getFilterQueryProvider();
        if (filter != null)
            return filter.runQuery(constraint);
    }
    mToken = token;
    final String constraintEscaped = constraint != null ? constraint.toString().replaceAll("_", "^_") : null;
    if (isAtSymbol(token)) {
        final Expression selection;
        final String[] selectionArgs;
        if (constraintEscaped != null) {
            final long[] nicknameIds = Utils.getMatchedNicknameIds(ParseUtils.parseString(constraint),
                    mUserColorNameManager);
            selection = Expression.or(Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"),
                    Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"),
                    Expression.in(new Column(CachedUsers.USER_ID), new RawItemArray(nicknameIds)));
            selectionArgs = new String[] { constraintEscaped, constraintEscaped };
        } else {
            selection = null;
            selectionArgs = null;
        }
        final OrderBy orderBy = new OrderBy(
                new String[] { CachedUsers.LAST_SEEN, "score", CachedUsers.SCREEN_NAME, CachedUsers.NAME },
                new boolean[] { false, false, true, true });
        final Cursor cursor = mResolver.query(
                Uri.withAppendedPath(CachedUsers.CONTENT_URI_WITH_SCORE, String.valueOf(mAccountId)),
                CachedUsers.BASIC_COLUMNS, selection != null ? selection.getSQL() : null, selectionArgs,
                orderBy.getSQL());
        if (BuildConfig.DEBUG && cursor == null)
            throw new NullPointerException();
        return cursor;
    } else {
        final String selection = constraintEscaped != null ? CachedHashtags.NAME + " LIKE ?||'%' ESCAPE '^'"
                : null;
        final String[] selectionArgs = constraintEscaped != null ? new String[] { constraintEscaped } : null;
        final Cursor cursor = mDatabase.query(true, CachedHashtags.TABLE_NAME, CachedHashtags.COLUMNS,
                selection, selectionArgs, null, null, CachedHashtags.NAME, null);
        if (BuildConfig.DEBUG && cursor == null)
            throw new NullPointerException();
        return cursor;
    }
}

From source file:org.opendatakit.common.android.provider.impl.FormsDiscoveryRunnable.java

/**
 * Scan the given formDir and update the Forms database. If it is the
 * formsFolder, then any 'framework' forms should be forbidden. If it is not
 * the/*  w w  w. ja v  a  2 s .co  m*/
 * formsFolder, only 'framework' forms should be allowed
 *
 * @param mediaPath
 *          -- full formDir
 * @param isFormsFolder
 * @param baseStaleMediaPath
 *          -- path prefix to the stale forms/framework directory.
 */
private final void updateFormDir(File formDir, boolean isFormsFolder, String baseStaleMediaPath) {

    String formDirectoryPath = formDir.getAbsolutePath();
    Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath);

    boolean needUpdate = true;
    FormInfo fi = null;
    Uri uri = null;
    Cursor c = null;
    try {
        File formDef = new File(formDir, ODKFileUtils.FORMDEF_JSON_FILENAME);

        String selection = FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH + "=?";
        String[] selectionArgs = { ODKFileUtils.asRelativePath(appName, formDir) };
        c = context.getContentResolver().query(Uri.withAppendedPath(formsProviderContentUri, appName), null,
                selection, selectionArgs, null);

        if (c == null) {
            Log.w(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath
                    + " null cursor -- cannot update!");
            return;
        }

        if (c.getCount() > 1) {
            c.close();
            Log.w(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath
                    + " multiple records from cursor -- delete all and restore!");
            // we have multiple records for this one directory.
            // Rename the directory. Delete the records, and move the
            // directory back.
            File tempMediaPath = moveToStaleDirectory(formDir, baseStaleMediaPath);
            context.getContentResolver().delete(Uri.withAppendedPath(formsProviderContentUri, appName),
                    selection, selectionArgs);
            FileUtils.moveDirectory(tempMediaPath, formDir);
            // we don't know which of the above records was correct, so
            // reparse this to get ground truth...
            fi = new FormInfo(context, appName, formDef);
        } else if (c.getCount() == 1) {
            c.moveToFirst();
            String id = c.getString(c.getColumnIndex(FormsColumns.FORM_ID));
            uri = Uri.withAppendedPath(Uri.withAppendedPath(formsProviderContentUri, appName), id);
            Long lastModificationDate = c.getLong(c.getColumnIndex(FormsColumns.DATE));
            Long formDefModified = ODKFileUtils.getMostRecentlyModifiedDate(formDir);
            if (lastModificationDate.compareTo(formDefModified) == 0) {
                Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath
                        + " formDef unchanged");
                fi = new FormInfo(appName, c, false);
                needUpdate = false;
            } else {
                Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " formDef revised");
                fi = new FormInfo(context, appName, formDef);
                needUpdate = true;
            }
        } else if (c.getCount() == 0) {
            // it should be new, try to parse it...
            fi = new FormInfo(context, appName, formDef);
        }

        // Enforce that a formId == FormsColumns.COMMON_BASE_FORM_ID can only be
        // in the Framework directory
        // and that no other formIds can be in that directory. If this is not the
        // case, ensure that
        // this record is moved to the stale directory.

        if (fi.formId.equals(FormsColumns.COMMON_BASE_FORM_ID)) {
            if (isFormsFolder) {
                // we have a 'framework' form in the forms directory.
                // Move it to the stale directory.
                // Delete all records referring to this directory.
                moveToStaleDirectory(formDir, baseStaleMediaPath);
                context.getContentResolver().delete(Uri.withAppendedPath(formsProviderContentUri, appName),
                        selection, selectionArgs);
                return;
            }
        } else {
            if (!isFormsFolder) {
                // we have a non-'framework' form in the framework directory.
                // Move it to the stale directory.
                // Delete all records referring to this directory.
                moveToStaleDirectory(formDir, baseStaleMediaPath);
                context.getContentResolver().delete(Uri.withAppendedPath(formsProviderContentUri, appName),
                        selection, selectionArgs);
                return;
            }
        }
    } catch (SQLiteException e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        return;
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        return;
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        try {
            FileUtils.deleteDirectory(formDir);
            Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath
                    + " Removing -- unable to parse formDef file: " + e.toString());
        } catch (IOException e1) {
            e1.printStackTrace();
            Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath
                    + " Removing -- unable to delete form directory: " + formDir.getName() + " error: "
                    + e.toString());
        }
        return;
    } finally {
        if (c != null && !c.isClosed()) {
            c.close();
        }
    }

    // Delete any entries matching this FORM_ID, but not the same directory and
    // which have a version that is equal to or older than this version.
    String selection;
    String[] selectionArgs;
    if (fi.formVersion == null) {
        selection = FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH + "!=? AND " + FormsColumns.FORM_ID + "=? AND "
                + FormsColumns.FORM_VERSION + " IS NULL";
        String[] temp = { ODKFileUtils.asRelativePath(appName, formDir), fi.formId };
        selectionArgs = temp;
    } else {
        selection = FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH + "!=? AND " + FormsColumns.FORM_ID + "=? AND "
                + "( " + FormsColumns.FORM_VERSION + " IS NULL" + " OR " + FormsColumns.FORM_VERSION + " <=?"
                + " )";
        String[] temp = { ODKFileUtils.asRelativePath(appName, formDir), fi.formId, fi.formVersion };
        selectionArgs = temp;
    }

    try {
        context.getContentResolver().delete(Uri.withAppendedPath(formsProviderContentUri, appName), selection,
                selectionArgs);
    } catch (SQLiteException e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        return;
    } catch (Exception e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        return;
    }

    // See if we have any newer versions already present...
    if (fi.formVersion == null) {
        selection = FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH + "!=? AND " + FormsColumns.FORM_ID + "=? AND "
                + FormsColumns.FORM_VERSION + " IS NOT NULL";
        String[] temp = { ODKFileUtils.asRelativePath(appName, formDir), fi.formId };
        selectionArgs = temp;
    } else {
        selection = FormsColumns.APP_RELATIVE_FORM_MEDIA_PATH + "!=? AND " + FormsColumns.FORM_ID + "=? AND "
                + FormsColumns.FORM_VERSION + " >?";
        String[] temp = { ODKFileUtils.asRelativePath(appName, formDir), fi.formId, fi.formVersion };
        selectionArgs = temp;
    }

    try {
        Uri uriApp = Uri.withAppendedPath(formsProviderContentUri, appName);
        c = context.getContentResolver().query(uriApp, null, selection, selectionArgs, null);

        if (c == null) {
            Log.w(t, "[" + instanceCounter + "] updateFormDir: " + uriApp.toString()
                    + " null cursor -- cannot update!");
            return;
        }

        if (c.moveToFirst()) {
            // the directory we are processing is stale -- move it to stale
            // directory
            moveToStaleDirectory(formDir, baseStaleMediaPath);
            return;
        }
    } catch (SQLiteException e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        return;
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + e.toString());
        return;
    } finally {
        if (c != null && !c.isClosed()) {
            c.close();
        }
    }

    if (!needUpdate) {
        // no change...
        return;
    }

    try {
        // Now insert or update the record...
        ContentValues v = new ContentValues();
        String[] values = fi.asRowValues(FormsColumns.formsDataColumnNames);
        for (int i = 0; i < values.length; ++i) {
            v.put(FormsColumns.formsDataColumnNames[i], values[i]);
        }

        if (uri != null) {
            int count = context.getContentResolver().update(uri, v, null, null);
            Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " " + count
                    + " records successfully updated");
        } else {
            context.getContentResolver().insert(Uri.withAppendedPath(formsProviderContentUri, appName), v);
            Log.i(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath
                    + " one record successfully inserted");
        }

    } catch (SQLiteException ex) {
        ex.printStackTrace();
        Log.e(t, "[" + instanceCounter + "] updateFormDir: " + formDirectoryPath + " exception: "
                + ex.toString());
        return;
    }
}

From source file:org.mariotaku.twidere.provider.TweetStoreProvider.java

@Override
public Uri insert(final Uri uri, final ContentValues values) {
    final String table = getTableNameForContentUri(uri);
    if (table == null)
        return null;
    if (TABLE_DIRECT_MESSAGES_CONVERSATION.equals(table))
        return null;
    else if (TABLE_DIRECT_MESSAGES.equals(table))
        return null;
    else if (TABLE_DIRECT_MESSAGES_CONVERSATIONS_ENTRY.equals(table))
        return null;
    final long row_id = mDatabase.insert(table, null, values);
    if (!"false".equals(uri.getQueryParameter(QUERY_PARAM_NOTIFY))) {
        switch (getTableId(uri)) {
        case URI_STATUSES: {
            mNewStatusesCount++;/*from w ww.ja va  2 s .com*/
            break;
        }
        case URI_MENTIONS: {
            mNewMentionsCount++;
            break;
        }
        case URI_DIRECT_MESSAGES_INBOX: {
            mNewMessagesCount++;
            break;
        }
        default:
        }
    }
    onDatabaseUpdated(uri);
    onNewItemsInserted(uri, 1, values);
    return Uri.withAppendedPath(uri, String.valueOf(row_id));
}

From source file:cx.ring.model.Conference.java

public void showCallNotification(Context ctx) {
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(ctx);
    notificationManager.cancel(notificationId);

    if (getParticipants().isEmpty())
        return;//from  w ww  .  j  a  v a 2 s. co  m
    SipCall call = getParticipants().get(0);
    CallContact contact = call.getContact();
    final Uri call_uri = Uri.withAppendedPath(SipCall.CONTENT_URI, call.getCallId());
    PendingIntent goto_intent = PendingIntent.getActivity(ctx, new Random().nextInt(), getViewIntent(ctx),
            PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder noti = new NotificationCompat.Builder(ctx);
    if (isOnGoing()) {
        noti.setContentTitle(ctx.getString(R.string.notif_current_call_title, contact.getDisplayName()))
                .setContentText(ctx.getText(R.string.notif_current_call)).setContentIntent(goto_intent)
                .addAction(R.drawable.ic_call_end_white_24dp, ctx.getText(R.string.action_call_hangup),
                        PendingIntent.getService(
                                ctx, new Random().nextInt(), new Intent(LocalService.ACTION_CALL_END)
                                        .setClass(ctx, LocalService.class).setData(call_uri),
                                PendingIntent.FLAG_ONE_SHOT));
    } else if (isRinging()) {
        if (isIncoming()) {
            noti.setContentTitle(ctx.getString(R.string.notif_incoming_call_title, contact.getDisplayName()))
                    .setPriority(NotificationCompat.PRIORITY_MAX)
                    .setContentText(ctx.getText(R.string.notif_incoming_call)).setContentIntent(goto_intent)
                    .setFullScreenIntent(goto_intent, true)
                    .addAction(R.drawable.ic_action_accept, ctx.getText(R.string.action_call_accept),
                            PendingIntent.getService(ctx, new Random().nextInt(),
                                    new Intent(LocalService.ACTION_CALL_ACCEPT)
                                            .setClass(ctx, LocalService.class).setData(call_uri),
                                    PendingIntent.FLAG_ONE_SHOT))
                    .addAction(R.drawable.ic_call_end_white_24dp, ctx.getText(R.string.action_call_decline),
                            PendingIntent.getService(ctx, new Random().nextInt(),
                                    new Intent(LocalService.ACTION_CALL_REFUSE)
                                            .setClass(ctx, LocalService.class).setData(call_uri),
                                    PendingIntent.FLAG_ONE_SHOT));
        } else {
            noti.setContentTitle(ctx.getString(R.string.notif_outgoing_call_title, contact.getDisplayName()))
                    .setContentText(ctx.getText(R.string.notif_outgoing_call)).setContentIntent(goto_intent)
                    .addAction(R.drawable.ic_call_end_white_24dp, ctx.getText(R.string.action_call_hangup),
                            PendingIntent.getService(
                                    ctx, new Random().nextInt(), new Intent(LocalService.ACTION_CALL_END)
                                            .setClass(ctx, LocalService.class).setData(call_uri),
                                    PendingIntent.FLAG_ONE_SHOT));
        }

    } else {
        notificationManager.cancel(notificationId);
        return;
    }

    noti.setOngoing(true).setCategory(NotificationCompat.CATEGORY_CALL).setSmallIcon(R.drawable.ic_launcher);

    if (contact.getPhoto() != null) {
        Resources res = ctx.getResources();
        int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height);
        int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width);
        noti.setLargeIcon(Bitmap.createScaledBitmap(contact.getPhoto(), width, height, false));
    }
    notificationManager.notify(notificationId, noti.build());
}

From source file:nl.sogeti.android.gpstracker.actions.Statistics.java

/**
 * Called when the activity is first created.
 *//* w ww.  ja  v  a  2 s  . c o  m*/
@Override
protected void onCreate(Bundle load) {
    super.onCreate(load);
    mUnits = new UnitsI18n(this, new UnitsI18n.UnitsChangeListener() {
        @Override
        public void onUnitsChange() {
            drawTrackingStatistics();
        }
    });
    setContentView(R.layout.statistics);
    Toolbar toolbar = (Toolbar) findViewById(R.id.support_actionbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mViewFlipper = (ViewFlipper) findViewById(R.id.flipper);
    mViewFlipper.setDrawingCacheEnabled(true);
    mSlideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
    mSlideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
    mSlideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
    mSlideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);

    mGraphTimeSpeed = (GraphCanvas) mViewFlipper.getChildAt(0);
    mGraphDistanceSpeed = (GraphCanvas) mViewFlipper.getChildAt(1);
    mGraphTimeAltitude = (GraphCanvas) mViewFlipper.getChildAt(2);
    mGraphDistanceAltitude = (GraphCanvas) mViewFlipper.getChildAt(3);

    mGraphTimeSpeed.setType(GraphCanvas.TIMESPEEDGRAPH);
    mGraphDistanceSpeed.setType(GraphCanvas.DISTANCESPEEDGRAPH);
    mGraphTimeAltitude.setType(GraphCanvas.TIMEALTITUDEGRAPH);
    mGraphDistanceAltitude.setType(GraphCanvas.DISTANCEALTITUDEGRAPH);

    mGestureDetector = new GestureDetector(new MyGestureDetector());

    maxSpeedView = (TextView) findViewById(R.id.stat_maximumspeed);
    mAscensionView = (TextView) findViewById(R.id.stat_ascension);
    mElapsedTimeView = (TextView) findViewById(R.id.stat_elapsedtime);
    overallavgSpeedView = (TextView) findViewById(R.id.stat_overallaveragespeed);
    avgSpeedView = (TextView) findViewById(R.id.stat_averagespeed);
    distanceView = (TextView) findViewById(R.id.stat_distance);
    starttimeView = (TextView) findViewById(R.id.stat_starttime);
    endtimeView = (TextView) findViewById(R.id.stat_endtime);
    waypointsView = (TextView) findViewById(R.id.stat_waypoints);

    if (load != null && load.containsKey(TRACKURI)) {
        mTrackUri = Uri.withAppendedPath(Tracks.CONTENT_URI, load.getString(TRACKURI));
    } else {
        mTrackUri = this.getIntent().getData();
    }
}

From source file:org.pencilsofpromise.rss.RSSFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    String projection[] = { RSSnote.RSS_tab.COL_TITLE, RSSnote.RSS_tab.COL_LINK, RSSnote.RSS_tab.COL_PUB_DATE,
            RSSnote.RSS_tab.COL_DESCRIPTION, RSSnote.RSS_tab.COL_CONTENT };
    Cursor tutorialCursor = getActivity().getContentResolver().query(
            Uri.withAppendedPath(RSSprovider.CONTENT_URI, String.valueOf(id)), projection, null, null, null);
    Intent itemintent = new Intent(getActivity(), ShowDescription.class);

    Bundle b = new Bundle();
    if (tutorialCursor.moveToFirst()) {

        b.putString("title", tutorialCursor.getString(0));
        b.putString("description", tutorialCursor.getString(3));
        b.putString("content", tutorialCursor.getString(4));
        b.putString("link", tutorialCursor.getString(1));
        b.putString("pubdate", tutorialCursor.getString(2));

    }// www.  j  a  v a2s  . co  m

    itemintent.putExtra("android.intent.extra.INTENT", b);

    startActivityForResult(itemintent, 0);
    tutorialCursor.close();

}