Fix RuntimeException on Android M Preview

This commit is contained in:
Anthony Restaino 2015-08-05 22:10:51 -04:00
parent 29d2a5f3e5
commit 5081ee2ea6
4 changed files with 10 additions and 6 deletions

View File

@ -1859,7 +1859,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
if (isSystemBrowserAvailable() && mPreferences.getSyncHistoryEnabled()) { if (isSystemBrowserAvailable() && mPreferences.getSyncHistoryEnabled()) {
try { try {
Browser.updateVisitedHistory(getContentResolver(), url, true); Browser.updateVisitedHistory(getContentResolver(), url, true);
} catch (NullPointerException ignored) { } catch (Exception ignored) {
// ignored
} }
} }
try { try {
@ -1890,10 +1891,9 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
String[] columns = new String[]{"url", "title"}; String[] columns = new String[]{"url", "title"};
boolean browserFlag; boolean browserFlag;
try { try {
Uri bookmarks = Browser.BOOKMARKS_URI; Uri bookmarks = Browser.BOOKMARKS_URI;
c = getContentResolver().query(bookmarks, columns, null, null, null); c = getContentResolver().query(bookmarks, columns, null, null, null);
} catch (SQLiteException | IllegalStateException | NullPointerException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -399,7 +399,7 @@ public class BookmarkManager {
* This method imports all bookmarks that are included in the device's * This method imports all bookmarks that are included in the device's
* permanent bookmark storage * permanent bookmark storage
*/ */
public synchronized void importBookmarksFromBrowser(Activity activity) { public synchronized void importBookmarksFromBrowser(Activity activity) throws Exception{
if (PreferenceManager.getInstance().getSystemBrowserPresent()) { if (PreferenceManager.getInstance().getSystemBrowserPresent()) {
List<HistoryItem> bookmarkList = new ArrayList<>(); List<HistoryItem> bookmarkList = new ArrayList<>();

View File

@ -74,7 +74,11 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
createDialog(); createDialog();
return true; return true;
case SETTINGS_BROWSER_IMPORT: case SETTINGS_BROWSER_IMPORT:
try {
mBookmarkManager.importBookmarksFromBrowser(getActivity()); mBookmarkManager.importBookmarksFromBrowser(getActivity());
} catch (Exception e) {
e.printStackTrace();
}
return true; return true;
default: default:
return false; return false;

View File

@ -44,7 +44,7 @@ public class WebUtils {
if (systemBrowserPresent) { if (systemBrowserPresent) {
try { try {
Browser.clearHistory(context.getContentResolver()); Browser.clearHistory(context.getContentResolver());
} catch (NullPointerException ignored) { } catch (Exception ignored) {
// ignored // ignored
} }
} }