本文主要是介绍Android Uri如何在intent中传输,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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 Uri如何在intent中传输的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!