Example usage for android.provider Browser HISTORY_PROJECTION_URL_INDEX

List of usage examples for android.provider Browser HISTORY_PROJECTION_URL_INDEX

Introduction

In this page you can find the example usage for android.provider Browser HISTORY_PROJECTION_URL_INDEX.

Prototype

int HISTORY_PROJECTION_URL_INDEX

To view the source code for android.provider Browser HISTORY_PROJECTION_URL_INDEX.

Click Source Link

Usage

From source file:mai.whack.StickyNotesActivity.java

private void onDataWrite(Intent intent) {
    byte[] tagId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
    Cursor mCur = this.managedQuery(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null, "DATE");
    // mCur.moveToFirst();
    if (mCur.moveToLast() && mCur.getCount() > 0) {
        String url = mCur.getString(Browser.HISTORY_PROJECTION_URL_INDEX);
        mHttpPostThread = new HttpPostThread(toHex(tagId), "tabs", url);
        mHttpPostThread.start();/*w w w.ja  v a  2 s  . co m*/
    }
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Utility method to load the list of browser bookmarks.
 *//*from ww  w  .java 2s  .  c  om*/
private static ArrayList<BookmarkInfo> loadBookmarks(Launcher context) {
    ArrayList<BookmarkInfo> bookmarks = new ArrayList<BookmarkInfo>();

    Cursor cursor = context.managedQuery(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        if (cursor.moveToFirst() && cursor.getCount() > 0) {
            while (cursor.isAfterLast() == false) {
                String bookmarkIndex = cursor.getString(Browser.HISTORY_PROJECTION_BOOKMARK_INDEX);
                if (bookmarkIndex != null && bookmarkIndex.equals("1")) {
                    BookmarkInfo bookmark = new BookmarkInfo();
                    String title = cursor.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX);
                    bookmark.setTitle(title);
                    String url = cursor.getString(Browser.HISTORY_PROJECTION_URL_INDEX);
                    bookmark.setUrl(url);

                    // for some reason the favicons aren't good looking
                    // images
                    // byte[] data =
                    // cursor.getBlob(Browser.HISTORY_PROJECTION_FAVICON_INDEX);
                    // if (data != null) {
                    // try {
                    // Bitmap bitmap = BitmapFactory.decodeByteArray(data,
                    // 0, data.length);
                    // bookmark.setDrawable(new FastBitmapDrawable(bitmap));
                    // } catch (Exception e) {
                    // Log.e(LOG_TAG, "bookmark icon", e);
                    // }
                    // }
                    bookmarks.add(bookmark);
                }

                cursor.moveToNext();
            }
        }
    }
    return bookmarks;
}

From source file:com.andrewshu.android.reddit.common.Common.java

public static boolean isClicked(Context context, String url) {
    Cursor cursor;//from ww  w .  j  ava 2  s.c  o m
    try {
        cursor = context.getContentResolver().query(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION,
                Browser.HISTORY_PROJECTION[Browser.HISTORY_PROJECTION_URL_INDEX] + "=?", new String[] { url },
                null);
    } catch (Exception ex) {
        if (Constants.LOGGING)
            Log.w(TAG, "Error querying Android Browser for history; manually revoked permission?", ex);
        return false;
    }

    if (cursor != null) {
        boolean isClicked = cursor.moveToFirst(); // returns true if cursor is not empty
        cursor.close();
        return isClicked;
    } else {
        return false;
    }
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Utility method to load the list of browser history.
 */// ww w  . j a  v a  2s.  c  o  m
private static ArrayList<BookmarkInfo> loadBrowserHistory(Launcher context) {
    ArrayList<BookmarkInfo> bookmarks = new ArrayList<BookmarkInfo>();

    Cursor cursor = context.managedQuery(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, null, null,
            Browser.BookmarkColumns.DATE + " DESC");
    if (cursor != null) {
        int count = 0;
        cursor.moveToFirst();
        if (cursor.moveToFirst() && cursor.getCount() > 0) {
            while (cursor.isAfterLast() == false) {
                String title = cursor.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX);
                String url = cursor.getString(Browser.HISTORY_PROJECTION_URL_INDEX);
                String bookmarkIndex = cursor.getString(Browser.HISTORY_PROJECTION_BOOKMARK_INDEX);
                Log.d(LOG_TAG, "bookmarkIndex=" + bookmarkIndex);
                if (url != null && title != null && !bookmarkIndex.equals("1")) {
                    // check for duplicates
                    boolean found = false;
                    for (BookmarkInfo bookmarkInfo : bookmarks) {
                        if (bookmarkInfo.getUrl() != null && bookmarkInfo.getUrl().equals(url)) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        BookmarkInfo bookmark = new BookmarkInfo();
                        bookmark.setTitle(title);
                        bookmark.setUrl(url);
                        bookmarks.add(bookmark);
                    }
                }
                cursor.moveToNext();
                if (++count >= BROWSER_HISTORY_LIMIT) {
                    break;
                }
            }
        }
    }
    return bookmarks;
}