[英]IllegalArgumentException while picking image from gallery on Sony z2
When I run script on Sony Z2 it throws this Exception, although it runs smoothly in Samsung s4: 当我在Sony Z2上运行脚本时,它会抛出此异常,尽管它在Samsung s4中运行平稳:
Caused by: java.lang.IllegalArgumentException: filename cannot be null
原因:java.lang.IllegalArgumentException:文件名不能为null
at (MyDetailsPage.java:274)
在(MyDetailsPage.java:274)
And here is my program and java:274 is in outside code: 这是我的程序,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;
}
Ok, It seems ridiculous, just writing answer and hope will help someone. 好吧,这似乎很荒谬,只写答案就可以对别人有所帮助。 It is really wierd how it affects whole code.
它如何影响整个代码真的很奇怪。 When calling intent I used
当我调用意图时
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
Instead of 代替
intent.setAction(Intent.ACTION_GET_CONTENT);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.