Skip to content

Commit

Permalink
fix Common.isClicked() for manually revoked browser permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
talklittle committed Jan 12, 2012
1 parent 769cb05 commit 4abce1a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/com/andrewshu/android/reddit/common/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,20 @@ public static void launchBrowser(Context context, String url, String threadUrl,
}

public static boolean isClicked(Context context, String url) {
Cursor cursor = context.getContentResolver().query(
Browser.BOOKMARKS_URI,
Browser.HISTORY_PROJECTION,
Browser.HISTORY_PROJECTION[Browser.HISTORY_PROJECTION_URL_INDEX] + "=?",
new String[]{ url },
null
);
Cursor cursor;
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();
Expand Down

0 comments on commit 4abce1a

Please sign in to comment.