繁体   English   中英

在Sony z2上从图库中选取图像时发生IllegalArgumentException

[英]IllegalArgumentException while picking image from gallery on Sony z2

当我在Sony Z2上运行脚本时,它会抛出此异常,尽管它在Samsung s4中运行平稳:

原因:java.lang.IllegalArgumentException:文件名不能为null

在(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;
    }

好吧,这似乎很荒谬,只写答案就可以对别人有所帮助。 它如何影响整个代码真的很奇怪。 当我调用意图时

Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);

代替

intent.setAction(Intent.ACTION_GET_CONTENT);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM