나는 안드로이드 전화 카메라에서 사진을 찍어 그것을 imageview에 올려 놓고있다. 이제 이미지 뷰의 src를 서버에 업로드 할 수있게하려고합니다. 이미지 뷰의 src를 어떻게 가져올 수 있습니까?android에서 src og imageview를 얻는 방법
여기
public class CameraActivity extends Activity implements View.OnClickListener {
ImageView iv;
Button bCapture, bSetWall;
Intent i;
int CameraResult = 0;
Bitmap bmp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initialize();
InputStream is = getResources().openRawResource(R.drawable.ic_launcher);
bmp = BitmapFactory.decodeStream(is);
}
private void initialize() {
iv = (ImageView)findViewById(R.id.ivCamera);
bCapture = (Button)findViewById(R.id.bCapture);
bSetWall = (Button)findViewById(R.id.bSetWall);
bCapture.setOnClickListener(this);
bSetWall.setOnClickListener(this);
}
public void onClick(View v) {
switch(v.getId()) {
case R.id.bCapture:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CameraResult);
break;
case R.id.bSetWall:
try {
getApplicationContext().setWallpaper(bmp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
iv.setImageBitmap(bmp);
//String v = iv.getTag().toString();
//Toast.makeText(getApplicationContext(), v, Toast.LENGTH_LONG).show();
}
}
}
그래서 내 코드에서이 줄 그때는'byteArray'을 업로드해야합니까를 추가 한 후? 둘째로 서버 측에서이 바이트 배열을 어떻게 다룰 것인가? – 2619
u는 바이트 배열을 base64 문자열로 변환하여 서버 – user1203673