2012-03-10 2 views
0

나는 이미지들을 가지고 있습니다. 나는 그것의 .JPEG 파일을 만들고 SD 카드의 전화 번호부에서 저장하고있다.이미지를 다운로드하고 안드로이드에서 활동을 보여줍니다.

모든 이미지 (비트 맵 만들기 및 JPEG로 압축)를 다운로드 한 후 해당 디렉토리에 다운로드 한 모든 이미지를 표시해야하는 다른 인 텐트를 호출합니다.

하지만 비어 있습니다.

나는 DDMS를 사로 잡았고 정확한 크기의 jpeg가 원하는 디렉토리에 다운로드되었음을 알았습니다. 그러나 내 의도는 보여주지 않습니다.

놀랍게도 에뮬레이터를 닫으면 다시 시작하고 다른 이미지 링크 세트로 프로그램을 실행하십시오. 이제 내 의도는 이전에 다운로드 한 이미지를 보여줍니다! (이 런 프로그램에서 다운로드 한 이미지가 아닙니다).

다음은 다운로드 한 이미지를 표시하는 데 사용하는 코드입니다. 아무도 도와 드릴 수 있습니까? 확인

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.imagechooser); 


     Bundle bundle = this.getIntent().getExtras(); 
     thumbNailsLnkdhs = (LinkedHashSet<String>) bundle.getSerializable("keyThumbNails"); 

     Toast.makeText(getApplicationContext(), 
       "ThumbNailsLnkdhs size in new intent: "+thumbNailsLnkdhs.size(), Toast.LENGTH_LONG).show(); 

     final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID }; 
     final String orderBy = MediaStore.Images.Media._ID; 


     Cursor imagecursor=managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
       columns, 
        MediaStore.Images.Media.DATA + " like ? ", 
        new String[] {"%myDesiredDirectory%"}, 
        null); 

     Log.d(LOGGER, "cursor made"); 
     int colcount=imagecursor.getColumnCount(); 
     //.d(LOGGER, "cursor column count is: "+colcount); 

     int count =imagecursor.getCount(); 
     //Log.d(LOGGER, "count is: "+count); 

     String colnAME=imagecursor.getColumnName(0); 
     //Log.d(LOGGER, "COL NAME FOR 0TH COLUMN="+colnAME); 
     String colnAME_1=imagecursor.getColumnName(1); 
     //Log.d(LOGGER, "COL NAME FOR 1st COLUMN="+colnAME_1); 


     int image_column_index = imagecursor.getColumnIndex(imagecursor.getColumnName(1)); 
     //Log.d(LOGGER, "image_column_index="+image_column_index); 

     //Log.d(LOGGER, "ThumbNailsLnkdhs size: "+ThumbNailsLnkdhs.size()); 

     //int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID); 


     this.count = imagecursor.getCount(); 
     //Log.d(LOGGER, "this.count="+this.count); 

     this.thumbnails = new Bitmap[this.count]; 
     this.arrPath = new String[this.count]; 
     this.thumbnailsselection = new boolean[this.count]; 

     for (int i = 0; i < this.count; i++) { 
      imagecursor.moveToPosition(i); 
      int id = imagecursor.getInt(image_column_index); 
      int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); 
      //Log.d(LOGGER, "dataColumnIndex="+dataColumnIndex); 

      thumbnails[i] = MediaStore.Images.Thumbnails.getThumbnail(
        getApplicationContext().getContentResolver(), id, 
        MediaStore.Images.Thumbnails.MICRO_KIND, null); 

      arrPath[i]= imagecursor.getString(dataColumnIndex); 
     } 
     GridView imagegrid = (GridView) findViewById(R.id.PhoneImageGrid); 
     imageAdapter = new ImageAdapter(); 
     imagegrid.setAdapter(imageAdapter); 
     imagecursor.close(); 
    } 

는 ANSR 아래의 제안에 따라, 그래서 나는 내가 물리적 파일을 만든 후 갤러리에 이미지를 삽입 할 필요가 발견했다.

나는
MediaStore.Images.Media.insertImage(getContentResolver(), bitmapimage, 
imgname+ ".jpg Card Image", "imgDescription" 
+ ".jpg Card Image"); 

을 시도했지만 실제 파일이 아니라 여관 활동을 생성 다운로드, 수업 시간에 메신저로 getcontentresolver 사용을 couldnt.

그래서 내가 이전에 이미지를 다운로드 표시합니다 내 활동

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" 
       +Environment.getExternalStorageDirectory() 
     + "/myDesiredDirectory/"))) 

을 시도 ...하지만 그것은 나를 새로 다운로드 한 이미지를 표시하는 데 도움을 didnt ... 그렇게

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" 

       + Environment.getExternalStorageDirectory()+))); 

    this also not showing new images :(

를 사람 수 시도 이걸 도와 줘?

답변

0

DDMS를 통해 이미지를 수동으로 AVD에 넣으면 설정에서 미디어를 스캔해야합니까?

같은 문제가 여기

다운로드 후, 당신은 코딩을 통해 미디어를 스캔하고 설정 어댑터 전에 이미지 커서를 닫아야합니다.

+0

감사합니다. 특정 디렉토리 만 검사하는 방법은? – adityag

+0

이제 내 활동에서 특정 디렉터 리를 스캔하는 방법을 찾고 있습니다. – adityag

0

새 ImageAdapter를 만든 다음 GridView를 해당 '새'어댑터에 연결합니다. 즉, GridView는 새로운 빈 어댑터에 연결되어 있으므로 빈 상태로 바인딩됩니다.

어디에서 비트 맵/커서를 어댑터 /보기에 연결합니까?

관련 문제