Android Uri如何在intent中传输
16lz
2021-01-23
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(); }
更多相关文章
- 图片拖动功能实现
- Android平台上实现图片的缩放,圆角,倒影效果
- android读取图片
- Android 使用Glide实现圆形和圆角图片
- 2012-7-20 android 图片叠加效果——两种方法
- Android文件图片上传的详细讲解(四)---服务端编码
- android处理大图片内存溢出的简单办法