Android Uri如何在intent中传输

来源:互联网 发布:淘宝单机游戏店铺赚钱 编辑:程序博客网 时间:2024/06/03 15:01

http://ask.csdn.net/questions/155


Uri对象在intent中传输

 Intent intent = new Intent(MainActivity.this, Homepage.class); intent.putExtra("image_uri", imageUri.toString()); startActivity(intent);

        //获取intent信息        Intent intent = getIntent();//获取用于启动Homepage的Intent        //显示图像        Uri imgUri = Uri.parse(intent.getStringExtra("image_uri"));        try {            Bitmap srcBitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imgUri));            if (srcBitmap == null) {                Toast.makeText(Homepage.this, "无法读取照片,检测失败", Toast.LENGTH_SHORT).show();                Log.i(TAG, "----------------------------------------Homepage 无法读取图片");                finish();            }            Bitmap myBitmap = Bitmap.createScaledBitmap(srcBitmap, 800, 600, true);            imageView.setImageBitmap(myBitmap); //显示拍照图片        } catch (FileNotFoundException e) {            e.printStackTrace();        }



0 0
原创粉丝点击