2014-09-24 73 views
1

我在Uri中使用了Content Provider發送文件。我用下面的代碼執行此操作:圖片使用Android內容提供商通過Instagram進行分享時破碎了圖片

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映像文件是。我嘗試了幾種方法,但未能解決問題。如果有人對此有任何想法,請幫助我。

在此先感謝。

回答

0

經過漫長的研究,我終於想出瞭解決這個問題的方法。在我目前正在開發的應用程序的一部分中,我必須將這些圖像下載到智能手機內部存儲器中。但是,如果圖片分辨率高(6480 x 4320)像素,則Galaxy Note 2無法上傳Instagram中的圖像。但對於低分辨率的圖像,它完美地工作。我想在下載圖像時,我必須修復圖像分辨率。所以,如果有人遇到這類問題,您必須首先關注圖像大小。

另一個重要的問題是,這種圖像尺寸問題只發生在Galaxy Note 2.對於其他設備,在Instagram上傳圖像時沒有問題。