Intent启动照片或者相机
1、
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.putExtra("crop", true); intent.putExtra("return-data", true); startActivityForResult(intent, 2); protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { System.out.println("requestCode" + requestCode); if (requestCode == 2) { Uri uri = data.getData(); ContentResolver cr = this.getContentResolver(); try { Bitmap bmp = BitmapFactory.decodeStream(cr .openInputStream(uri)); img1.setImageBitmap(bmp); img1.setVisibility(View.VISIBLE); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
Done