Android 图片选择器

1 事件调用,RESULT_LOAD_IMAGE = 1

Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);  
    			   
startActivityForResult(i, RESULT_LOAD_IMAGE);
2 选择文件后,返回结果
protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        super.onActivityResult(requestCode, resultCode, data);  
      
        if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {  
            Uri selectedImage = data.getData();  
            String[] filePathColumn = { MediaStore.Images.Media.DATA };  
      
            Cursor cursor = getContentResolver().query(selectedImage,  
                    filePathColumn, null, null, null);  
            cursor.moveToFirst();  
      
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);  
            
            picturePath = cursor.getString(columnIndex);  
            
            Bitmap bitmap = BitmapFactory.decodeFile(picturePath);
            
            ImageView image = (ImageView) screenShow.findViewById(R.id.hw_update_screen_image_view1);
    		image.setImageBitmap(bitmap);           
    		screenImage = bitmap;
    		
            cursor.close();  
            
        }  
    }







































你可能感兴趣的:(android,MediaStore)