I'm trying to add a new bookmark in my web browser, the bookmark is succefully added, but, the program throw an exception after adding the bookmark, I explain :
When Browser.saveBookmark is called , I can fill url and title values and then select "save". The item is successfully added to the list. Then, The message displays: "Sorry! The application Browser (process com.android.browser) has stopped unexpectedly. Please try again."
Here is my source code :
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == MENU_ADD) {
Browser.saveBookmark(this, "New Bookmark", "http://");
return true;
} else
return false;
}
The stack trace in Logcat is as follows :
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): FATAL EXCEPTION: Thread-11
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at android.os.Handler.<init>(Handler.java:121)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at android.webkit.WebIconDatabase$EventHandler.<init>(WebIconDatabase.java:46)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at android.webkit.WebIconDatabase$EventHandler.<init>(WebIconDatabase.java:46)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at android.webkit.WebIconDatabase.<init>(WebIconDatabase.java:43)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at android.webkit.WebIconDatabase.getInstance(WebIconDatabase.java:293)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at com.android.browser.Bookmarks.addBookmark(Bookmarks.java:136)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at com.android.browser.AddBookmarkPage$SaveBookmarkRunnable.run(AddBookmarkPage.java:136)
01-03 14:47:25.862: ERROR/AndroidRuntime(1720): at java.lang.Thread.run(Thread.java:1096)
I have already tried this way to add a bookmark (instead Browser.saveBookmark) :
Intent i = new Intent(Intent.ACTION_INSERT, android.provider.Browser.BOOKMARKS_URI);
i.putExtra("title", title);
i.putExtra("url", url);
this.startActivity(i);
But, this gave me the same error!
So, any workaround on this bug or any other solution to add a bookmark? Thanks in advance