@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == 0) { requestAllState(); } else if (requestCode == FLAG_CHOOSE_IMG && resultCode == RESULT_OK) { // 选择图片 if (data != null) { Uri uri = data.getData(); if (!TextUtils.isEmpty(uri.getAuthority())) { Cursor cursor = getContentResolver() .query(uri, new String[] {MediaStore.Images.Media.DATA}, null, null, null); if (null == cursor) { Toast.makeText(this, "图片没找到", Toast.LENGTH_SHORT).show(); return; } cursor.moveToFirst(); String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)); cursor.close(); Log.i("===", "path=" + path); Intent intent = new Intent(this, CropImageActivity.class); intent.putExtra("path", path); startActivityForResult(intent, FLAG_MODIFY_FINISH); } else { Log.i("===", "path=" + uri.getPath()); Intent intent = new Intent(this, CropImageActivity.class); intent.putExtra("path", uri.getPath()); startActivityForResult(intent, FLAG_MODIFY_FINISH); } } } else if (requestCode == FLAG_CHOOSE_PHONE && resultCode == RESULT_OK) { // 拍照 File f = new File(FILE_PIC_SCREENSHOT, localTempImageFileName); Intent intent = new Intent(this, CropImageActivity.class); intent.putExtra("path", f.getAbsolutePath()); startActivityForResult(intent, FLAG_MODIFY_FINISH); } else if (requestCode == FLAG_MODIFY_FINISH && resultCode == RESULT_OK) { if (data != null) { final String path = data.getStringExtra("path"); Log.i("===", "截取到的图片路径是 = " + path); Bitmap b = BitmapFactory.decodeFile(path); headImageView.setImageBitmap(b); headerImageStr = bitmap2Base64(b); requestSetUserLogo(); } } }