0

我正在尝试用我的应用拍照,保存并检索网址。目前我有:

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);

public void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) 
    {
        case TAKE_PICTURE:
        {
            if (resultCode == RESULT_OK) 
            {
                File file = new File(getPath(data.getData()));

                Date dt = new Date(file.lastModified());
                String datum = dt.toLocaleString();

                Comment_Resource photo = new Comment_Resource(file.getAbsolutePath(), datum, true);


            }
            break;
        }
      }
}

这适用于某些手机,但很多手机不保存导致空指针的图片。

4

1 回答 1

0

尝试这个:

Uri uri = Uri.fromFile(file);
于 2013-06-10T12:18:32.527 回答