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 回答