to top
Android APIs
public class

Browser

extends Object
java.lang.Object
   ↳ android.provider.Browser

Summary

Nested Classes
class Browser.BookmarkColumns Column definitions for the mixed bookmark and history items available at BOOKMARKS_URI
class Browser.SearchColumns Column definitions for the search history table, available at SEARCHES_URI
Constants
String EXTRA_APPLICATION_ID The name of the extra data when starting the Browser from another application.
String EXTRA_CREATE_NEW_TAB Boolean extra passed along with an Intent to a browser, specifying that a new tab be created.
String EXTRA_HEADERS The name of the extra data in the VIEW intent.
int HISTORY_PROJECTION_BOOKMARK_INDEX
int HISTORY_PROJECTION_DATE_INDEX
int HISTORY_PROJECTION_FAVICON_INDEX
int HISTORY_PROJECTION_ID_INDEX
int HISTORY_PROJECTION_TITLE_INDEX
int HISTORY_PROJECTION_URL_INDEX
int HISTORY_PROJECTION_VISITS_INDEX
String INITIAL_ZOOM_LEVEL The name of extra data when starting Browser with ACTION_VIEW or ACTION_SEARCH intent.
int SEARCHES_PROJECTION_DATE_INDEX
int SEARCHES_PROJECTION_SEARCH_INDEX
int TRUNCATE_HISTORY_PROJECTION_ID_INDEX
int TRUNCATE_N_OLDEST
Fields
public static final Uri BOOKMARKS_URI A table containing both bookmarks and history items.
public static final String[] HISTORY_PROJECTION
public static final String[] SEARCHES_PROJECTION A projection of SEARCHES_URI that contains _ID, SEARCH, and DATE.
public static final Uri SEARCHES_URI A table containing a log of browser searches.
public static final String[] TRUNCATE_HISTORY_PROJECTION
Public Constructors
Browser()
Public Methods
final static void addSearchUrl(ContentResolver cr, String search)
Add a search string to the searches database.
final static boolean canClearHistory(ContentResolver cr)
Returns whether there is any history to clear.
final static void clearHistory(ContentResolver cr)
Delete all entries from the bookmarks/history table which are not bookmarks.
final static void clearSearches(ContentResolver cr)
Remove all searches from the search database.
final static void deleteFromHistory(ContentResolver cr, String url)
Remove a specific url from the history database.
final static void deleteHistoryTimeFrame(ContentResolver cr, long begin, long end)
Delete all history items from begin to end.
final static Cursor getAllBookmarks(ContentResolver cr)
Return a cursor pointing to a list of all the bookmarks.
final static Cursor getAllVisitedUrls(ContentResolver cr)
Return a cursor pointing to a list of all visited site urls.
final static void requestAllIcons(ContentResolver cr, String where, WebIconDatabase.IconListener listener)
Request all icons from the database.
final static void saveBookmark(Context c, String title, String url)
Open an activity to save a bookmark.
final static void sendString(Context context, String string)
Sends the given string using an Intent with ACTION_SEND and a mime type of text/plain.
final static void truncateHistory(ContentResolver cr)
If there are more than MAX_HISTORY_COUNT non-bookmark history items in the bookmark/history table, delete TRUNCATE_N_OLDEST of them.
final static void updateVisitedHistory(ContentResolver cr, String url, boolean real)
Update the visited history to acknowledge that a site has been visited.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String EXTRA_APPLICATION_ID

Added in API level 3

The name of the extra data when starting the Browser from another application.

The value is a unique identification string that will be used to identify the calling application. The Browser will attempt to reuse the same window each time the application launches the Browser with the same identifier.

Constant Value: "com.android.browser.application_id"

public static final String EXTRA_CREATE_NEW_TAB

Added in API level 12

Boolean extra passed along with an Intent to a browser, specifying that a new tab be created. Overrides EXTRA_APPLICATION_ID; if both are set, a new tab will be used, rather than using the same one.

Constant Value: "create_new_tab"

public static final String EXTRA_HEADERS

Added in API level 8

The name of the extra data in the VIEW intent. The data are key/value pairs in the format of Bundle. They will be sent in the HTTP request headers for the provided url. The keys can't be the standard HTTP headers as they are set by the WebView. The url's schema must be http(s).

Constant Value: "com.android.browser.headers"

public static final int HISTORY_PROJECTION_BOOKMARK_INDEX

Added in API level 1

Constant Value: 4 (0x00000004)

public static final int HISTORY_PROJECTION_DATE_INDEX

Added in API level 1

Constant Value: 3 (0x00000003)

public static final int HISTORY_PROJECTION_FAVICON_INDEX

Added in API level 1

Constant Value: 6 (0x00000006)

public static final int HISTORY_PROJECTION_ID_INDEX

Added in API level 1

Constant Value: 0 (0x00000000)

public static final int HISTORY_PROJECTION_TITLE_INDEX

Added in API level 1

Constant Value: 5 (0x00000005)

public static final int HISTORY_PROJECTION_URL_INDEX

Added in API level 1

Constant Value: 1 (0x00000001)

public static final int HISTORY_PROJECTION_VISITS_INDEX

Added in API level 1

Constant Value: 2 (0x00000002)

public static final String INITIAL_ZOOM_LEVEL

Added in API level 1

The name of extra data when starting Browser with ACTION_VIEW or ACTION_SEARCH intent.

The value should be an integer between 0 and 1000. If not set or set to 0, the Browser will use default. If set to 100, the Browser will start with 100%.

Constant Value: "browser.initialZoomLevel"

public static final int SEARCHES_PROJECTION_DATE_INDEX

Added in API level 1

Constant Value: 2 (0x00000002)

public static final int SEARCHES_PROJECTION_SEARCH_INDEX

Added in API level 1

Constant Value: 1 (0x00000001)

public static final int TRUNCATE_HISTORY_PROJECTION_ID_INDEX

Added in API level 1

Constant Value: 0 (0x00000000)

public static final int TRUNCATE_N_OLDEST

Added in API level 1

Constant Value: 5 (0x00000005)

Fields

public static final Uri BOOKMARKS_URI

Added in API level 1

A table containing both bookmarks and history items. The columns of the table are defined in Browser.BookmarkColumns. Reading this table requires the READ_HISTORY_BOOKMARKS permission and writing to it requires the WRITE_HISTORY_BOOKMARKS permission.

public static final String[] HISTORY_PROJECTION

Added in API level 1

public static final String[] SEARCHES_PROJECTION

Added in API level 1

A projection of SEARCHES_URI that contains _ID, SEARCH, and DATE.

public static final Uri SEARCHES_URI

Added in API level 1

A table containing a log of browser searches. The columns of the table are defined in Browser.SearchColumns. Reading this table requires the READ_HISTORY_BOOKMARKS permission and writing to it requires the WRITE_HISTORY_BOOKMARKS permission.

public static final String[] TRUNCATE_HISTORY_PROJECTION

Added in API level 1

Public Constructors

public Browser ()

Added in API level 1

Public Methods

public static final void addSearchUrl (ContentResolver cr, String search)

Added in API level 1

Add a search string to the searches database. Requires READ_HISTORY_BOOKMARKS Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.
search The string to add to the searches database.

public static final boolean canClearHistory (ContentResolver cr)

Added in API level 1

Returns whether there is any history to clear. Requires READ_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.
Returns
  • boolean True if the history can be cleared.

public static final void clearHistory (ContentResolver cr)

Added in API level 1

Delete all entries from the bookmarks/history table which are not bookmarks. Also set all visited bookmarks to unvisited. Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.

public static final void clearSearches (ContentResolver cr)

Added in API level 1

Remove all searches from the search database. Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.

public static final void deleteFromHistory (ContentResolver cr, String url)

Added in API level 1

Remove a specific url from the history database. Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.
url url to remove.

public static final void deleteHistoryTimeFrame (ContentResolver cr, long begin, long end)

Added in API level 1

Delete all history items from begin to end. Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.
begin First date to remove. If -1, all dates before end. Inclusive.
end Last date to remove. If -1, all dates after begin. Non-inclusive.

public static final Cursor getAllBookmarks (ContentResolver cr)

Added in API level 1

Return a cursor pointing to a list of all the bookmarks. The cursor will have a single column, URL.

Requires READ_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.

public static final Cursor getAllVisitedUrls (ContentResolver cr)

Added in API level 1

Return a cursor pointing to a list of all visited site urls. The cursor will have a single column, URL.

Requires READ_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.

public static final void requestAllIcons (ContentResolver cr, String where, WebIconDatabase.IconListener listener)

Added in API level 1

Request all icons from the database. This call must either be called in the main thread or have had Looper.prepare() invoked in the calling thread. Requires READ_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.
where Clause to be used to limit the query from the database. Must be an allowable string to be passed into a database query.
listener IconListener that gets the icons once they are retrieved.

public static final void saveBookmark (Context c, String title, String url)

Added in API level 1

Open an activity to save a bookmark. Launch with a title and/or a url, both of which can be edited by the user before saving.

Parameters
c Context used to launch the activity to add a bookmark.
title Title for the bookmark. Can be null or empty string.
url Url for the bookmark. Can be null or empty string.

public static final void sendString (Context context, String string)

Added in API level 1

Sends the given string using an Intent with ACTION_SEND and a mime type of text/plain. The string is put into EXTRA_TEXT.

Parameters
context the context used to start the activity
string the string to send

public static final void truncateHistory (ContentResolver cr)

Added in API level 1

If there are more than MAX_HISTORY_COUNT non-bookmark history items in the bookmark/history table, delete TRUNCATE_N_OLDEST of them. This is used to keep our history table to a reasonable size. Note: it does not prune bookmarks. If the user wants 1000 bookmarks, the user gets 1000 bookmarks. Requires READ_HISTORY_BOOKMARKS Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.

public static final void updateVisitedHistory (ContentResolver cr, String url, boolean real)

Added in API level 1

Update the visited history to acknowledge that a site has been visited. Requires READ_HISTORY_BOOKMARKS Requires WRITE_HISTORY_BOOKMARKS

Parameters
cr The ContentResolver used to access the database.
url The site being visited.
real If true, this is an actual visit, and should add to the number of visits. If false, the user entered it manually.