2012-04-16 1 views
0

응용 프로그램 갤러리에서 이미지를 업로드 할 때 이미지를 일부 선택했을 때 예외가 발생했습니다.galleryActivity에서 이미지를로드하는 중 원래 여기에 추가 된 창이 누출 되었습니까?

android.view.WindowLeaked: Activity has leaked window [email protected] that was originally added here 

android.view.WindowManagerImpl.addView(Win 

dowManagerImpl.java:152) 는 I didn 히, 나는 무작위로 예외를 가지고 왜 t에 ?? 코드 아래

이 코드가 열려 갤러리입니다 ..

Intent intent = new Intent(); 
     intent.setType("image/*"); 
     intent.setAction(Intent.ACTION_GET_CONTENT); 
     ((Activity) context).startActivityForResult(Intent.createChooser(intent,"Select Picture"), PICK_FROM_FILE); 

내가

f (resultCode == RESULT_OK) 
        { 

         Uri contentUri = data.getData(); 
         System.out.println("**************contentUri***************"+contentUri); 
         String[] proj = { MediaStore.Images.Media.DATA }; 
         Cursor cursor = managedQuery(contentUri, proj, null, null, null); 
         int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 
         cursor.moveToFirst(); 
         String tmppath = cursor.getString(column_index); 
         // File abc= new File(tmppath); 
         System.out.println("**************tmppath***************"+tmppath); 

         Bitmap mBitmap = BitmapFactory.decodeFile(tmppath); 
         // Bitmap bitmap = BitmapFactory.decodeFile(abc); 
         System.out.println("**************mBitmap(gallery)***************"+mBitmap); 
         Court_formations objectdat =new Court_formations(); 
         objectdat.showGalleryimage(getDialogContext(),mBitmap); 

PLZ이 코드를 사용해보십시오으로 onActivity 결과에

+0

코드 붙여 넣기 –

+0

horizonall 모드에서 갤러리를 열면 potrait 모드로 고정 된 상태로 응용 프로그램으로 돌아올 때이 예외가 발생했습니다 – user1287756

+0

그냥 galery에서 이미지를 가져 와서 imageview에 표시하고 있습니까? –

답변

1

도움 갤러리 에서 bimap를 얻기위한 것입니다 :

Uri selectedImageUri = Uri.parse(data.getDataString()); 
ContentResolver cr = getContentResolver(); 
InputStream in = null; 
try { 
in = cr.openInputStream(selectedImageUri); 
} catch (FileNotFoundException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inSampleSize=20; 
Bitmap mBitmap = BitmapFactory.decodeStream(in,null,options); 
Court_formations objectdat =new Court_formations(); 
objectdat.showGalleryimage(getDialogContext(),mBitmap); 
+0

위의 경우 귀하의 문제를 해결하지 못하면 다음을 추가하십시오. 매니 페스트 파일에서 귀하의 활동에 대한 이들을 추가하십시오 : configChanges = "keyboardHidden | orientation" –

+0

고맙습니다, 문제가 해결되었습니다. – user1287756

+0

나는 약간의 이미지에 대해 하나의 문제가 있습니다. bitmap = null .. – user1287756

관련 문제