【问题标题】:Real path of Android pictures from photo gallery来自照片库的Android图片的真实路径
【发布时间】:2013-03-28 06:35:02
【问题描述】:

我想对照片库中的图片进行图像处理。

所以,我正在通过读取图像文件来开发适用于 android Bitmap 的模块。 从我的 Titanium 应用程序中,我打开照片库并将 event.media.file.nativePath 发送到我的模块。

但是,它似乎找不到它,因为当我创建一个

File file = new File(path)

我得到一个 file.exists() == false。我从媒体上得到的路径在我的手机上是这样的: file:///content://......../data/data.......jpg

有没有办法从 Ti.Media.openPhotoGallery 的媒体创建 Android 位图?

【问题讨论】:

    标签: android titanium titanium-modules


    【解决方案1】:

    "file:///content://......./data/data.........jpg" 这个文件路径似乎在 BlackBerry 上。你可以像这样获得外部存储:

    Environment.getExternalStorageDirectory().getAbsolutePath();
    

    然后你可以添加路径到你的文件。

    【讨论】:

      【解决方案2】:

      请!试试下面的示例代码。

      Uri selectedImageUri = **put your content url**;
      String[] filePathColumn = {MediaStore.Images.Media.DATA};
       cursor = getContentResolver().query(
      , filePathColumn, null, null, null);
      .moveToFirst();
      
       columnIndex = cursor.getColumnIndex(filePathColumn[0]);
       filePath = cursor.getString(columnIndex);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-11
        • 1970-01-01
        • 2011-05-31
        • 1970-01-01
        • 1970-01-01
        • 2019-02-01
        • 2013-01-20
        相关资源
        最近更新 更多