2012-04-16 3 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) 私はなかったの。私はランダムに例外を得た理由は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

horizo​​nallモードでギャラリーを開いたときにアプリケーションに戻ってpotraitモードで修正したら、この例外が発生しました – user1287756

+0

galeryからイメージをピックアップしてイメージビューに表示していますか? –

答えて

1

を助けるギャラリー から2領域マップを取得するためです。

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

上記の問題が解決しない場合は、マニフェストファイルのアクティビティにこれらを追加してください:android:configChanges = "keyboardHidden | orientation" –

+0

問題を解決してくれてありがとう – user1287756

+0

私はビットマップ=ヌルを持っている画像に1つ問題があります... – user1287756

関連する問題