Using the function below I am trying to get the LAST url that the user visited from Chrome Browser on their Android Phone. This function works very well for most sites, but does not work for "www.reddit.com".
The url variable below updates if I go to "www.google.com", "www.hulu.com" or "www.kayak.com" but will not update if I go to "www.reddit.com".
It does update if I go to "m.reddit.com". Same problem with facebook, detects m.facebook.com but not www.facebook.com.
I don't understand What's the difference between "www.reddit.com" and "m.reddit.com" that Android records one but not the other.
What change do I need in the code to detect ALL URL ACCESSES?
public String returnLastChromeURL(int browserCode) {
String[] proj = new String[] { Browser.BookmarkColumns.DATE,
Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL };
String dateTime;
Uri uriCustom = Uri
.parse("content://com.android.chrome.browser/bookmarks");
String sel = Browser.BookmarkColumns.BOOKMARK + " = 0"; // 0 = history,
// 1 = bookmark
try {
Cursor mCur = mContext.getContentResolver().query(uriCustom, proj, sel,
null, BookmarkColumns.DATE + " ASC");
mCur.moveToFirst();
mCur.moveToLast();
dateTime = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.DATE));
title = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.TITLE));
url = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.URL));
mCur.close();
} catch (Exception e) {
dateTime = String.valueOf(System.currentTimeMillis());
title = "";
url = "empty_list";
}
return url;
}
Some more info from my debug:
- When I try this on a Genymotion Emulator, all websites (including sites like
www.reddit.comget detected ok). On a real phonewww.reddit.comdoes not get detected. - Sites the code will detect OK:
www.kayak.com' (redirects towww.kayak.com/mn),www.hulu.com(loads mobile version of site though url stays www.hulu.com),www.google.com` (same story as the hulu).
Seems like that the sites that load the pure desktop version of the site, do not get detected
