在Image CROP之后传递结果失败RuntimeException

时间:2012-06-13 11:02:42

标签: android file-io bitmap

裁剪图像后

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(resultCode != RESULT_OK)
    {
        return;
    }
    switch (requestCode) {
    case CROP_FROM_CAM:{

        final Bundle extras = data.getExtras();

        if(extras !=null){
            Bitmap photo = extras.getParcelable("data");
            profile_photo.setImageBitmap(photo);
            Profile_photo_save_path =Profile_photo_save_path+"profile_"+String.valueOf(System.currentTimeMillis())+".png"; 

            SaveBitmapToFile(photo, Profile_photo_save_path);
            update_my_profile_photo(Profile_photo_save_path);
        }

在CROP Image,OnActivityResult

之后
06-13 19:57:26.855: E/AndroidRuntime(5733): java.lang.RuntimeException: Failure   delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.gpon.android/com.gpon.android.setting}: java.lang.NullPointerException

并且可能在SaveBitmapToFile方法中出现错误,

private void SaveBitmapToFile(Bitmap photo , String FilePath){
    File fileItem = new File(FilePath);
    OutputStream out = null;
    try {
        fileItem.createNewFile();
        out = new FileOutputStream(fileItem);
        photo.compress(CompressFormat.PNG, 100, out);
    } catch (Exception e) {
        // TODO: handle exception
    }
    finally{

        try {
            out.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

这是来源。 当我跳过保存时,错误没有发生

0 个答案:

没有答案