2013-11-03 2 views
0

parse.com을 사용하고 있는데 이미지를 검색하는 데 문제가 있습니다.android에서 parse.com에서 이미지를 가져 오는 중 문제가 발생했습니다.

ParseFile fileObject = (ParseFile) comment.get("ac"); 
      fileObject.getDataInBackground(new GetDataCallback() { 

         @Override 
         public void done(byte[] data, 
           ParseException e) { 
          if (e == null) { 

           // Decode the Byte[] into 
           // Bitmap 
           try { 
           Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length); 

           // Get the ImageView from 
           // main.xml 
           String root = Environment.getExternalStorageDirectory().toString(); 
           File myDir = new File(root + "/imagesuri1/");  


           String fname = "image-"+ n +".jpg"; 

           n++; 
           File file = new File (myDir, fname); 
           if (file.exists()) 
            {file.delete();} 

             FileOutputStream out = new FileOutputStream(file); 
             bmp.compress(Bitmap.CompressFormat.JPEG, 90, out); 

             out.flush(); 
             out.close(); 
           } catch (Exception b) { 
             b.printStackTrace(); 
           } 
           // Close progress dialog 

           progressDialog.dismiss(); 
          } 
         else { 
     Toast.makeText(getApplicationContext(), "ha abido un problema", Toast.LENGTH_SHORT).show(); 
          } 

         } 



        }); 
     } 
     } 


    }); 

no++; 

특히, 문제는 내가 parse.com 3 개 이미지를 가지고 내가 디코딩, 모든 이미지를 검색 및 SD 카드에 저장하고있어 것입니다 :이 코드입니다. 때때로 이미지는 다음과 같이 반환됩니다 : (image-0.jpg - 0) (image-1.jpg - 1) (image-2.jpg - 2). 이것이 내가 원하는거야. 때때로 이미지는 다음과 같이 반환됩니다. (image-0.jpg - 0) (image-2.jpg - 1) (image-1.jpg - 2). 나는 왜 그런지 이해하지 못한다.

파일 크기 문제입니까? 조언이나 해결책으로 도움을 받으십시오. 제 질문이 올바르게 이루어지면 왜 이런 결과를 낳을까요?

답변

0

쿼리에 대한 코드가 표시되지 않지만 주문 문제가 발생한 곳일 수 있습니다. '교류'필드에 의해로 이미지의 순서를 강제로 쿼리에 다음과 같은 논리를 넣어

시도 :

// Sorts the results in ascending order by the ac field 
query.orderByAscending("ac"); 

이 더 많은 정보를 위해 Query Constraints section of the Parse Android Docs를 참조하십시오.

관련 문제