在做项目过程中,要给后台传图片并显示在用户端的界面上,下次登录后会读取上传到后台的信息并显示;
也就是http://blog.csdn.net/gly742279097/article/details/41700505这一块
遇到两个问题:
1、拍照后显示的图片被旋转,所以上传到后台后在显示也是被旋转了
解决方法:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Bitmap photo = null;
if (requestCode == 999) {
if (file != null && file.exists()) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
path = file.getPath();
photo = BitmapUtils.opBigBitmap(path, ChangeInfoActivity.this, 70, 70);
}
} else if (requestCode == 888) {
if (data == null) {
return;
}
Uri uri = data.getData();
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = this.managedQuery(uri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
path = cursor.getString(column_index);
sp.edit().putString("person_path_location", path).commit();
if (photo != null && !photo.isRecycled())// 如果不释放的话,不断取图片,将会内存不够
{
photo.recycle();
photo = null;
}
System.gc();
photo = Bitm