在应用程序中,我打开图库并选择图像我必须在对话框中显示该图像..但有时它会返回位图值 =null.. 有时它具有位图值不显示对话框..它通过异常即
java.lang.NullPointerException
04-16 10:11:52.310: WARN/System.err(1395): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:432)
04-16 10:11:52.310: WARN/System.err(1395): at myclassname.onActivityResult
对于 iopen 画廊,我使用了下面的代码
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
((Activity) context).startActivityForResult(Intent.createChooser(intent,"Select Picture"), PICK_FROM_FILE);
敌人从画廊获取数据我使用了这个代码
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Activity.RESULT_OK)
{
Uri selectedImage = data.getData();
try {
Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
请帮助..