保存为ByteArrayOutputStream的WebView.getFavicon()的java.lang.NullPointerException

时间:2013-03-12 17:37:51

标签: android sqlite bitmap

我正在尝试将网页的favicon添加到sqlite数据库,但在尝试通过java.lang.NullPointerException将favicon保存到ByteArrayOutputStream时,我得到Bitmap.compress

我的代码片段是:

Bitmap bitmap = view.getFavicon(); 
    mySQLiteAdapter.openToWrite();
    ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();

    bitmap.compress(CompressFormat.PNG, 0, byteArrayBitmapStream);
    byte[] bArray = byteArrayBitmapStream.toByteArray();
    String[] comments = new String[] {view.getUrl()};
    String[] commentss = new String[] {view.getTitle()};
    int nextInt = new Random().nextInt(1);
    try{
     mySQLiteAdapter.insert(bArray, commentss[nextInt], comments[nextInt]);
    }catch (Exception e) {
         e.printStackTrace();
    }
    mySQLiteAdapter.close();

为什么我收到此错误?

0 个答案:

没有答案