0

アプリケーションでギャラリーから画像をアップロードすると、いくつかの画像を選択すると、この例外が発生しました。

android.view.WindowLeaked: Activity  has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4133c7d8 that was originally added here

android.view.WindowManagerImpl.addView(Win

dowManagerImpl.java:152) なぜランダムに例外が発生したのですか??

このコードはオープンギャラリー用です..

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

以下のコードは、ギャラリー i から bimap を取得するためのものです

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);

助けてください

4

1 に答える 1

1

onactivityの結果では、次のコードを使用してみてください。

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);
于 2012-04-16T07:48:49.110 に答える