我在片段中使用LoadBitmap()并在片段外返回null。 在我的应用程序中我有4个选项卡片段,并且从4个片段中的一个我有loadbitmap的返回代码,它用于从库中加载图像,同时检查其密度和所有。图像得到正确附加但在发送任何图像后我点击其他选项卡然后应用程序崩溃并通过loadbitmap函数中的空指针异常异常
public void loadBitmap(Message message, ImageView imageView) {
Bitmap bm;
try {
bm = xmppConnectionService.getFileBackend().getThumbnail(message,
(int) (metrics.density * 288), true);
} catch (FileNotFoundException e) {
bm = null;
}
if (bm != null) {
cancelPotentialWork(message, imageView);
imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000);
} else {
if (cancelPotentialWork(message, imageView)) {
imageView.setBackgroundColor(0xff333333);
imageView.setImageDrawable(null);
final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
final AsyncDrawable asyncDrawable = new AsyncDrawable(
getResources(), null, task);
imageView.setImageDrawable(asyncDrawable);
try {
task.execute(message);
} catch (final RejectedExecutionException ignored) {
ignored.printStackTrace();
}
}
}
}
在这一行,我收到了错误 bm = xmppConnectionService.getFileBackend()。getThumbnail(message, (int)(metrics.density * 288),true);
请帮我解决片段问题如何管理片段
中的位图