Android手机上的Uri问题

时间:2013-01-27 15:18:34

标签: android bitmap android-activity uri

我想在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
         }
       }
      }

0 个答案:

没有答案