从Sony z2上的图库中选择图像时出现IllegalArgumentException

时间:2015-12-18 20:20:10

标签: java android illegalargumentexception

当我在索尼Z2上运行脚本时,它会引发此异常,尽管它在三星s4中运行顺利:

  

引起:java.lang.IllegalArgumentException:filename不能   空

     

at(MyDetailsPage.java:274)

这是我的程序和java:274在外部代码中:

 public  Bitmap decodeScaledDownBitmapFromDatabase(String imagePath,int requiredHeight,int requiredWidth){
       final BitmapFactory.Options options=new BitmapFactory.Options();
        options.inJustDecodeBounds=true;
        Bitmap bitmap=BitmapFactory.decodeFile(imagePath, options);
        Matrix matrix;

        options.inSampleSize=calculateInputImageSize(options, requiredHeight, requiredWidth);
        options.inJustDecodeBounds=false;
        bitmap =BitmapFactory.decodeFile(imagePath, options);
        int angel=0;


                    try{

java : 276         ExifInterface exifInterface=new ExifInterface(imagePath);

                   int orientation=exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_UNDEFINED);

                   if (orientation==ExifInterface.ORIENTATION_ROTATE_90){
                   angel=90;
                   }
                   else if(orientation==ExifInterface.ORIENTATION_ROTATE_180){
                angel=180;
            }
            else if (orientation==ExifInterface.ORIENTATION_ROTATE_270){
                angel=270;
            }
        }
        catch (IOException e){
            Toast.makeText(getApplicationContext(),"Image could not be selected",Toast.LENGTH_LONG).show();
        }
        matrix=new Matrix();
        matrix.postRotate(angel);
        Bitmap readyBitmap=Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);

        return readyBitmap;
    }

0 个答案:

没有答案