我使用以下代码拍摄图像并将其分配给 ImageView。它在 Kindle Fire HD (API 15) 上运行良好,但在 Google Nexus 7 上,该设备正在流式传输来自 Google Picassa 的照片。如何让 Picassa/流媒体照片正常工作?
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
protected void onActivityResult(int requestCode, int resultCode,
Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case SELECT_PHOTO:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(
selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
Bitmap pic = BitmapFactory.decodeFile(filePath);
mProfilePic = new BitmapDrawable(getResources(),pic);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
mChangePicImgButton.setBackground(mProfilePic);
else
mChangePicImgButton.setBackgroundDrawable(mProfilePic);
}
}
}