采用contentprivider扫描手机SD卡的图片资源

时间:2014-05-26 22:50:19   收藏:0   阅读:369
bubuko.com,布布扣
Intent inten = new Intent(
                    Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(inten,21);




------------------------在onActivityResult中加入-------------------


Uri uri = data.getData();
            String[] filePath = { MediaStore.Images.Media.DATA };
            Cursor c = getContentResolver().query(uri, filePath,
                    null, null, null);
            c.moveToFirst();
            int columnIndex = c.getColumnIndex(filePath[0]);
            Log.e("autobot", columnIndex+"");
            String picturePath = c.getString(columnIndex);
            Log.e("autobot", picturePath);
            c.close();
            Bitmap  bitmap = ImageManager.decodeScaledBitmap(picturePath, 400, 200);
            image.setImageBitmap(bitmap);
bubuko.com,布布扣

 

采用contentprivider扫描手机SD卡的图片资源,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!