【问题标题】:Image Broken while sharing through Instagram using Android Content Provider使用 Android 内容提供程序通过 Instagram 共享时图像损坏
【发布时间】:2018-02-25 08:01:09
【问题描述】:

我使用 Content Provider 在 Uri 中发送文件。我已经使用以下代码来执行此操作:

public Uri fileSharingUsingContentProvider(File tempFile)
{
 String filePath = tempFile.getAbsolutePath(); // tempFile is the image file ....
 Cursor mCursor = this.getApplicationContext().getContentResolver().query(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            new String[] { MediaStore.Images.Media._ID },
            MediaStore.Images.Media.DATA + "=? ",
            new String[] { filePath }, null);


  if(mCursor != null && mCursor.moveToFirst()){

        int id = mCursor.getInt(mCursor.getColumnIndex(MediaStore.MediaColumns._ID));
        Uri baseUri = Uri.parse("content://media/external/images/media");


        Trace.d(TAG,"<==> The baseUri after parsing : " + Uri.withAppendedPath(baseUri, ""+id));
        return Uri.withAppendedPath(baseUri, "" + id);
  }
  else {
        if (tempFile.exists()) {
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.DATA, filePath);

            return this.getApplicationContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
        } 
        else {
            return null;
        }
   }
}

但问题是,当我尝试通过 Instagram 进行分享时,此代码完美适用于除图像文件损坏的 Galaxy Note 2 之外的所有设备。我尝试了几种方法,但未能解决问题。如果有人对这件事有任何想法,请帮助我。

提前致谢。

【问题讨论】:

    标签: android android-contentprovider instagram


    【解决方案1】:

    经过长时间的研究,我终于找到了解决这个问题的方法。在我目前正在开发的应用程序的一部分中,我必须将图像下载到智能手机内部存储中。但是,如果图片分辨率很高,例如 (6480 x 4320) 像素,则 Galaxy Note 2 无法将图片上传到 Instagram。但是对于低分辨率图像,它可以完美运行。我想在下载图像时,我必须修复图像分辨率。因此,如果有人遇到此类问题,您必须首先关注图像大小。

    另一个重要的问题是,这个图片大小问题只发生在 Galaxy Note 2 中。对于其他设备,在 Instagram 上传图片时没有问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 2020-12-29
      相关资源
      最近更新 更多