我想在BitMap
通过Uri
解码OnActivityResult
。当我直接提供图片网址时,例如sdcard / image / x.jpg我可以获得位图,但是当我尝试BitmapFactory.decodeFile(uri.toString)
程序崩溃时。
我使用galaxy s我知道galaxy s手机有一个错误,uri被返回为null。我该怎么做才能得到那个uri?
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == req) {
Uri u=data.getData();
Bitmap photo = (Bitmap) data.getExtras().get("data"); //gets thumbnail
try {
Bitmap pa= BitmapFactory.decodeFile(u.toString());//supposed to get the image in real size but crashes the application
Bitmap pa= BitmapFactory.decodeFile("sdcard/image/x.jpg";//works well
//do stuff
}
}
}