Android Emulator显示SD卡上的图像

Android Emulator显示SD卡上的图像,android,android-imageview,android-image,Android,Android Imageview,Android Image,你好!!我正在尝试编写一个非常简单的android程序。当我在图像库中的选定图像上按共享按钮时,会弹出一个菜单,告诉我在我的应用程序和要打开图像的消息传递应用程序之间进行选择。当我选择我的应用程序时,我希望它在图像视图中查看图像。对于我已经做的部分是隐含的意图,当我按下共享按钮时,它会弹出一个菜单供我选择要使用的应用程序。第二部分是棘手的部分,因为图像保存在手机的SD卡上。如何访问特定图像以及如何在图像视图中查看图像?我正在使用Android仿真器首先创建一个具有SD卡的仿真器 要从SD卡中拾取

你好!!我正在尝试编写一个非常简单的android程序。当我在图像库中的选定图像上按
共享按钮
时,会弹出一个菜单,告诉我在我的应用程序和要打开图像的消息传递应用程序之间进行选择。当我选择我的应用程序时,我希望它在
图像视图中查看图像。对于我已经做的部分是隐含的意图,当我按下共享按钮时,它会弹出一个菜单供我选择要使用的应用程序。第二部分是棘手的部分,因为图像保存在手机的SD卡上。如何访问特定图像以及如何在
图像视图中查看图像?我正在使用Android仿真器

首先创建一个具有SD卡的仿真器

要从SD卡中拾取图像,您可以按照

用于在您的imageview中显示该图像


请显示您的代码。emulator中没有SD卡。我认为您的emulator的SD卡中没有图像
protected void onActivityResult(int requestCode, int resultCode, 
       Intent imageReturnedIntent) {
    super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

    switch(requestCode) { 
    case REQ_CODE_PICK_IMAGE:
        if(resultCode == RESULT_OK){  
            Uri selectedImage = imageReturnedIntent.getData();
            String[] filePathColumn = {MediaStore.Images.Media.DATA};

            Cursor cursor = getContentResolver().query(
                               selectedImage, filePathColumn, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String filePath = cursor.getString(columnIndex);
            cursor.close();


            Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
            yourImageView.setImageBitmap(yourSelectedImage);
        }
    }
}
ImageView img=(ImageView) findViewById(R.id.ur_imageview);
Bitmap bmp = BitmapFactory.decodeFile(filePath);
img.setImageBitmap(bmp);