为什么我会收到 NullpointerException?
谢谢!
ps:我是Java新手。
try {
URL uri = new URL("http://static.panoramio.com/photos/original/41455707.jpg");
URLConnection connection = uri.openConnection();
Log.i(TAG, "connecting...");
connection.connect();
InputStream is = connection.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 8 * 1024);
Bitmap bmp = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
Log.i(TAG, "setting bitmap");
//Log.d(TAG, canvas.toString());
//Log.d(TAG, bmp.toString());
canvas.setBitmap(bmp);
} catch (Exception exc){
Log.e(TAG, exc.toString());
return;
}
输出:
06-28 17:29:04.857 391 397 I MyWallpaperPainting: connecting...
06-28 17:29:07.248 391 397 I MyWallpaperPainting: setting bitmap
06-28 17:29:07.248 391 397 E MyWallpaperPainting: java.lang.NullPointerException