[英]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.