how to create a web Bookmark with thumbnails android widgets?

时光毁灭记忆、已成空白 提交于 2020-01-06 08:10:40

问题


Could anybody know how to make web bookmark with thumbnails? please give me an idea on how to get the thumbnails or screen shoots of current bookmark websites..

this is the widget that I would like to learn..


回答1:


This is for ICS+ only :

Browser API is being revamped along the lines of Contacts API, now bookmarks are linked to Accounts and also have a folder structure.As far as I know, new Internals have not been exposed via public API calls, and all implementations are likely to be changed in future, and your App might stop working then, if you use internal API. Still, its worth while to know internal workings of android browser provider:

In BrowserProvider2 . Now, thumbnails are in a different table, and have their own URI. But internally, they are placing data in images table, this also has a URI.

Have a look at structure of new Bookmarks table and Thumbnails table and Images table. Then , see how bookmarks are being inserted :

  • Legacy calls
  • Bookmarks insert
  • Extraction of thumbnails etc
  • Extracted Images insertion

Also, BrowserContract has these columns defined as ImageColumns these store, thumbnails, favicon, and touch icons etc.

Finally, query() has matches for IMAGES (no id, url is primary key) and THUMBNAILS (with id).

So, from here you can get whatever images you need using new CONTENT_URI of BrowserContract, append it with URI's of Images,Thumbnails etc and run your queries/inserts .




回答2:


I think for thumbnails you put your link on webView and save your webView under bitmap. Then you save bitmap on SD card and your have your thumbnail.

You can get bookmarks like this :

Cursor mCur  = ActivityChooseBookmark.this.getContentResolver().query(android.provider.Browser.BOOKMARKS_URI,
                        projection, Browser.BookmarkColumns.BOOKMARK, null, null);

Use this to get your bitmap from webView :

public static Bitmap getBitmapFromView(View view) {
        Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(returnedBitmap);
        Drawable bgDrawable = view.getBackground();
        if (bgDrawable!=null) 
            bgDrawable.draw(canvas);
        else 
            canvas.drawColor(Color.TRANSPARENT);
        view.draw(canvas);
        return returnedBitmap;
    }

Now just save it on SD and it's done



来源:https://stackoverflow.com/questions/13562019/how-to-create-a-web-bookmark-with-thumbnails-android-widgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!