private void sendImage(Bitmap bm)
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 60, stream);
byte[] bytes = stream.toByteArray();
String img = new String(Base64.encodeToString(bytes, Base64.DEFAULT));
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.add("img", img);
client.post("http:xxx/postIcon", params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int i, Header[] headers, byte[] bytes) {
Toast.makeText(MainActivity.this, "Upload Success!", Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
Toast.makeText(MainActivity.this, "Upload Fail!", Toast.LENGTH_LONG).show();
}
});
}