NPE in DownloadTouchIcon because of getPreferredHttpHost
The call getPreferredHttpHost needs a context, however there
are two constructors of the class, one of them does not take
a context as input. Added context parameter to the second
constructor.
Change-Id: Ibe670c5b8848ced88b0756d83d5c13e0961652ae
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index 1104d5e..594f985 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -18,6 +18,7 @@
import android.app.Activity;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
@@ -116,7 +117,9 @@
*/
private class SaveBookmarkRunnable implements Runnable {
private Message mMessage;
- public SaveBookmarkRunnable(Message msg) {
+ private Context mContext;
+ public SaveBookmarkRunnable(Context ctx, Message msg) {
+ mContext = ctx;
mMessage = msg;
}
public void run() {
@@ -135,7 +138,7 @@
final ContentResolver cr = getContentResolver();
Bookmarks.addBookmark(null, cr, url, title, thumbnail, true);
if (touchIconUrl != null) {
- new DownloadTouchIcon(cr, url).execute(mTouchIconUrl);
+ new DownloadTouchIcon(mContext, cr, url).execute(mTouchIconUrl);
}
mMessage.arg1 = 1;
} catch (IllegalStateException e) {
@@ -237,7 +240,7 @@
Message msg = Message.obtain(mHandler, SAVE_BOOKMARK);
msg.setData(bundle);
// Start a new thread so as to not slow down the UI
- Thread t = new Thread(new SaveBookmarkRunnable(msg));
+ Thread t = new Thread(new SaveBookmarkRunnable(getApplicationContext(), msg));
t.start();
setResult(RESULT_OK);
LogTag.logBookmarkAdded(url, "bookmarkview");