如何在android中将图像附加到请求url

如何在android中将图像附加到请求url,android,web-services,image-uploading,putimagedata,Android,Web Services,Image Uploading,Putimagedata,我做了一个活动,我从相机或图库中选择了一张图片,必须通过将其名称和数据附加到url上传到服务器上,我听说要将其转换为二进制或imageData并附加到requestURL以通过服务器上传。但我真的不知道怎么做,任何人都可以帮我修改我的代码吗?请>。我的代码如下: My url is:http://yehki.epagestore.in//app_api/buying_request.php?customer_id=6&product_name=checkapi&category_

我做了一个活动,我从相机或图库中选择了一张图片,必须通过将其名称和数据附加到url上传到服务器上,我听说要将其转换为二进制或imageData并附加到requestURL以通过服务器上传。但我真的不知道怎么做,任何人都可以帮我修改我的代码吗?请>。我的代码如下:

My url is:http://yehki.epagestore.in//app_api/buying_request.php?customer_id=6&product_name=checkapi&category_id=1&expire_time=09-05-90&detail_desc=somedec&esti_ordr_qty=200&esti_ordr_qty_unit=1&filename=t1231he.jpg&image=" "
main.java


嘿,你有这个任务的web服务吗??告诉我你以前试过什么???@rahu请看我的更新代码..我已经试过了。但是它给了我非法参数异常,所以我认为ByTestStream不正确encoded@RahulGupta请查看我的更新代码..我已经尝试过了.但它给了我非法参数异常,所以我认为bytestream不合适encoded@RahulGupta-我有一个日志…请检查它的朋友。!我会查的,会给你答案的,好吗
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_buying_request);

    InitializeView();
    productCategory.setOnClickListener(this);
    send.setOnClickListener(this);
    expTime.setOnClickListener(this);
    proImg.setOnClickListener(this);

    dateandtime = Calendar.getInstance(Locale.US);
    header.back.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });

    reqList = new ArrayList<HashMap<String, String>>();
    queList = new ArrayList<HashMap<String, String>>();
    viewReq.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            flag = 2;
            reqList.clear();
            iv_fav_menu.setBackgroundResource(R.drawable.tab_two_fav);

            callGetQuoteListAsyncTask();

            scr_view.setVisibility(View.VISIBLE);
            quote_view.setVisibility(View.GONE);
            rl_botm.setVisibility(View.GONE);
            scr_post.setVisibility(View.GONE);

        }
    });

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            in = new Intent(getApplicationContext(), BuyingRequestDetailActivity.class);

            // getting ProductId from the tag...

            String buyReqID = reqList.get(position).get(Const.TAG_BUYING_REQUEST_ID);

            System.out.println(":::::::::::::::;;THE INTENT FOR THE resuest DETIALS ACTIVITY=================" + buyReqID);
            in.putExtra(Const.TAG_BUYING_REQUEST_ID, buyReqID);
            in.putExtra(Const.TAG_QUOTE_ID, quote_id);
            System.out.println("::::::::::::Buyer Id and Request Id::::::::;" + buyReqID + " ====>" + quote_id);
            startActivity(in);
        }

    });
    quoteList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            in = new Intent(getApplicationContext(), QuoteDetailActivity.class);

            // getting ProductId from the tag...

            reqID = queList.get(position).get(Const.TAG_BUYING_REQUEST_ID);
            quote_id = queList.get(position).get(Const.TAG_QUOTE_ID);
            System.out.println(":::::::::::::::;;THE INTENT FOR THE resuest DETIALS ACTIVITY=================" + reqID);
            in.putExtra(Const.TAG_BUYING_REQUEST_ID, reqID);
            in.putExtra(Const.TAG_QUOTE_ID, quote_id);
            System.out.println("::::::::::::Buyer Id and Request Id::::::::;" + reqID + " ====>" + quote_id);
            startActivity(in);
        }
    });
    postReq.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            flag = 1;
            iv_fav_menu.setBackgroundResource(R.drawable.tab_one_fav);
            quote_view.setVisibility(View.GONE);
            scr_post.setVisibility(View.VISIBLE);
            rl_botm.setVisibility(View.VISIBLE);
            scr_view.setVisibility(View.GONE);

        }
    });

}

@Override
public void onClick(View v) {
    Intent i;
    switch (v.getId()) {

    case R.id.tv_pro_cat:
        i = new Intent(BuyingreqActivity.this, ProCategoryActivity.class);
        startActivityForResult(i, 10);

        break;
    case R.id.tv_pro_exp_tym:

        DatePickerDailog dp = new DatePickerDailog(BuyingreqActivity.this, dateandtime, new DatePickerDailog.DatePickerListner() {

            @Override
            public void OnDoneButton(Dialog datedialog, Calendar c) {
                datedialog.dismiss();
                dateandtime.set(Calendar.YEAR, c.get(Calendar.YEAR));
                dateandtime.set(Calendar.MONTH, c.get(Calendar.MONTH));
                dateandtime.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH));
                expTime.setText(new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()));
            }

            @Override
            public void OnCancelButton(Dialog datedialog) {
                // TODO Auto-generated method stub
                datedialog.dismiss();
            }
        });
        dp.show();

        break;
    case R.id.btn_send:
        new postBuyingReqList().execute();

        break;
    case R.id.iv_img:
        showCustomeAlert2(BuyingreqActivity.this, "Yehki", "From Camera", "From Gallery");

        break;

    }

}

@SuppressWarnings("deprecation")
private void showCustomeAlert2(Context context, String title, String rightButton, String leftButton) {
    final Dialog dialog = new Dialog(BuyingreqActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    dialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    dialog.setContentView(R.layout.popup_alert);
    dialog.setCancelable(false);
    final ImageView btn_lft = (ImageView) dialog.findViewById(R.id.iv_left);
    final ImageView btn_rgt = (ImageView) dialog.findViewById(R.id.iv_right);
    final Button cancel = (Button) dialog.findViewById(R.id.btn_cancle);

    final TextView btn_left = (TextView) dialog.findViewById(R.id.btnLeft);
    final TextView btn_right = (TextView) dialog.findViewById(R.id.btnRight);

    btn_left.setText(leftButton);
    btn_right.setText(rightButton);
    cancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    btn_rgt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                System.out.println("=========== perform click ==============");
                String mediaStorageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getPath();

                fileName = "user_" + Pref.getValue(BuyingreqActivity.this, Const.PREF_USER_ID, 0) + "_" + System.currentTimeMillis() + ".png";
                imageUri = Uri.fromFile(new File(Const.DIR_USER + "/" + fileName));

                System.out.println(" PATH ::: " + imageUri);

                Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

                cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(cameraIntent, CAMERA_CAPTURE);

            } catch (ActivityNotFoundException anfe) {
                String errorMessage = "Whoops - your device doesn't support capturing images!";

            }

            dialog.dismiss();
        }
    });
    btn_lft.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            // call android default gallery
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            // ******** code for crop image
            intent.putExtra("crop", "true");
            intent.putExtra("aspectX", 0);
            intent.putExtra("aspectY", 0);
            intent.putExtra("outputX", 200);
            intent.putExtra("outputY", 200);

            try {

                intent.putExtra("return-data", true);
                startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_GALLERY);

            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

void InitializeView() {
    iv_fav_menu = (ImageView) findViewById(R.id.iv_fav_menu);
    viewReq = (Button) findViewById(R.id.btn_view);
    postReq = (Button) findViewById(R.id.btn_post);
    scr_post = (ScrollView) findViewById(R.id.scr_post);
    scr_view = (RelativeLayout) findViewById(R.id.scr_view);
    quote_view = (RelativeLayout) findViewById(R.id.quote_view);
    quoteList = (ListView) findViewById(R.id.quote_list);

    lv = (ListView) findViewById(R.id.req_list);
    rl_botm = (RelativeLayout) findViewById(R.id.rl_botm);
    header = (Header) findViewById(R.id.headerBuying);
    header.title.setText("Post Buying Request");
    proImg = (ImageView) findViewById(R.id.iv_img);
    productName = (EditText) findViewById(R.id.et_pro_name);
    productCategory = (TextView) findViewById(R.id.tv_pro_cat);
    expTime = (TextView) findViewById(R.id.tv_pro_exp_tym);
    productDesc = (EditText) findViewById(R.id.et_pro_desc);
    estOrderQty = (TextView) findViewById(R.id.et_est_qty);
    send = (Button) findViewById(R.id.btn_send);

}

/*
 * getting buying request list...!!!
 */
private class GetBuyingReqList extends AsyncTask<Void, Void, Void> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        // Showing progress dialog
        pDialog = new ProgressDialog(BuyingreqActivity.this);
        pDialog.setMessage("Please wait...");
        pDialog.setCancelable(false);

        pDialog.show();

    }

    @Override
    protected Void doInBackground(Void... arg0) {

        String query = "?customer_id=" + Pref.getValue(BuyingreqActivity.this, Const.PREF_CUSTOMER_ID, "");
        query = query.replace(" ", "%20");
        viewURL = Const.API_BUYING_REQUEST_LIST + query;
        BackendAPIService sh = new BackendAPIService();

        System.out.println(":::::::::::::::::::ADDRESS URL:::::::::::::::::" + viewURL);
        // Making a request to url and getting response
        String jsonStr = sh.makeServiceCall(viewURL, BackendAPIService.GET);

        Log.d("Response: ", "> " + jsonStr);
        try {
            if (jsonStr != null) {

                jsonObj = new JSONObject(jsonStr);

                if (jsonObj.has(Const.TAG_BUYING_REQUEST)) {
                    System.out.println("::::::::::::::::true::::::::::::::::" + jsonObj.has(Const.TAG_ADDRESS_LIST));
                    requestes = jsonObj.getJSONArray(Const.TAG_BUYING_REQUEST);

                    if (requestes != null && requestes.length() != 0) {
                        // looping through All Contacts

                        System.out.println(":::::::::::FLAG IN SUB:::::::::::" + flag);
                        for (int i = 0; i < requestes.length(); i++) {
                            JSONObject c = requestes.getJSONObject(i);

                            String buyer_request_id = c.getString(Const.TAG_BUYING_REQUEST_ID);
                            System.out.println(":::::::::::::::MY buying request:::::::::::::" + buyer_request_id);
                            String subject = c.getString(Const.TAG_PRODUCT_NAME);
                            String date_modified = c.getString(Const.TAG_DATE_MODIFIED);
                            String expired_date = c.getString(Const.TAG_EXPIRY_DATE);
                            String quote_count = c.getString(Const.TAG_QUOTE_COUNT);
                            String buying_request_status = c.getString(Const.TAG_BUYING_REQUEST_STATUS);

                            HashMap<String, String> request = new HashMap<String, String>();

                            request.put(Const.TAG_BUYING_REQUEST_ID, buyer_request_id);
                            request.put(Const.TAG_PRODUCT_NAME, subject);
                            request.put(Const.TAG_DATE_MODIFIED, date_modified);
                            request.put(Const.TAG_EXPIRY_DATE, expired_date);
                            request.put(Const.TAG_QUOTE_COUNT, quote_count);
                            request.put(Const.TAG_BUYING_REQUEST_STATUS, buying_request_status);
                            reqList.add(request);
                            System.out.println("::::::::::::::::REQUEST IDS::::::::::::" + buyer_request_id);

                        }
                    }
                }

            } else {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

        } catch (JSONException e) {
            e.printStackTrace();
            System.out.println("::::::::::::::::::got an error::::::::::::");
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        // Dismiss the progress dialog
        if (pDialog.isShowing())
            pDialog.dismiss();
        /**
         * Updating parsed JSON data into ListView
         * 
         * */

        buyingRequestContent = new BuyingRequestAdapter(BuyingreqActivity.this, reqList);

        lv.setAdapter(buyingRequestContent);

    }

}

public void callGetQuoteListAsyncTask() {
    new GetBuyingReqList().execute();
}

/*
 * getting qoute List...!!!
 */
public class GetQuoteList extends AsyncTask<String, Void, Void> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        // Showing progress dialog
        queList.clear();
        pDialog = new ProgressDialog(BuyingreqActivity.this);
        pDialog.setMessage("Please wait...");
        pDialog.setCancelable(false);
        scr_post.setVisibility(View.GONE);
        scr_view.setVisibility(View.GONE);
        quote_view.setVisibility(View.VISIBLE);
        pDialog.show();

    }

    @Override
    protected Void doInBackground(String... arg0) {

        // String query = "?customer_id=" +
        // Pref.getValue(BuyingreqActivity.this, Const.PREF_CUSTOMER_ID, "")
        // + "&buyer_request_id=23";
        String reqID = arg0[0];
        String query = "?customer_id=" + Pref.getValue(BuyingreqActivity.this, Const.PREF_CUSTOMER_ID, "") + "&buyer_request_id=" + reqID;
        query = query.replace(" ", "%20");
        viewURL = Const.API_QUOTE_RECIEVED + query;
        BackendAPIService sh = new BackendAPIService();

        System.out.println(":::::::::::::::::::ADDRESS URL:::::::::::::::::" + viewURL);
        // Making a request to url and getting response
        String jsonStr = sh.makeServiceCall(viewURL, BackendAPIService.GET);

        Log.d("Response: ", "> " + jsonStr);
        try {
            if (jsonStr != null) {

                jsonObj = new JSONObject(jsonStr);

                if (jsonObj.has(Const.TAG_BUYING_REQUEST)) {
                    System.out.println("::::::::::::::::true::::::::::::::::" + jsonObj.has(Const.TAG_ADDRESS_LIST));
                    requestes = jsonObj.getJSONArray(Const.TAG_BUYING_REQUEST);

                    if (requestes != null && requestes.length() != 0) {
                        // looping through All Contacts

                        System.out.println(":::::::::::FLAG IN SUB:::::::::::" + flag);
                        for (int i = 0; i < requestes.length(); i++) {
                            JSONObject c = requestes.getJSONObject(i);

                            buyerID = c.getString(Const.TAG_BUYING_REQUEST_ID);
                            System.out.println(":::::::::::::::MY buying request:::::::::::::" + buyerID);
                            String product_name = c.getString(Const.TAG_PRODUCT_NAME);
                            String quote_id = c.getString(Const.TAG_QUOTE_ID);
                            String supplier_name = c.getString(Const.TAG_SUPPLIER_NAME);
                            String status = c.getString(Const.TAG_STATUS);

                            HashMap<String, String> quote = new HashMap<String, String>();

                            quote.put(Const.TAG_BUYING_REQUEST_ID, buyerID);
                            quote.put(Const.TAG_PRODUCT_NAME, product_name);
                            quote.put(Const.TAG_QUOTE_ID, quote_id);
                            quote.put(Const.TAG_EXPIRY_DATE, supplier_name);
                            quote.put(Const.TAG_QUOTE_COUNT, status);
                            queList.add(quote);
                            System.out.println(":::::::::::::Buyer request ID:" + buyerID);
                        }
                    }
                }

            } else {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

        } catch (JSONException e) {
            e.printStackTrace();
            System.out.println("::::::::::::::::::got an error::::::::::::");
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        // Dismiss the progress dialog
        if (pDialog.isShowing())
            pDialog.dismiss();
        /**
         * Updating parsed JSON data into ListView
         * 
         * */

        quoteAdapter = new QuoteAdapter(BuyingreqActivity.this, queList);

        quoteList.setAdapter(quoteAdapter);

    }

}

// ============================
/*
 * post Buying Request api()...!!!
 */
private class postBuyingReqList extends AsyncTask<Void, Void, Void> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        // Showing progress dialog
        pDialog = new ProgressDialog(BuyingreqActivity.this);

        pDialog.setMessage("Please wait...");
        pDialog.setCancelable(false);
        pDialog.show();

    }

    @Override
    protected Void doInBackground(Void... arg0) {
        postURL = Const.API_BUYING_REQUEST + "?customer_id=" + Pref.getValue(BuyingreqActivity.this, Const.PREF_CUSTOMER_ID, "") + "&product_name=" + productName.getText().toString().trim()
                + "&category_id=" + id + "&expire_time=" + expTime.getText().toString() + "&detail_desc=" + productDesc.getText().toString().trim() + "&esti_ordr_qty="
                + estOrderQty.getText().toString().trim() + "&esti_ordr_qty_unit=1&filename=" + fileName + "&image=" + encodedImage;
        // Creating service handler class instance
        postURL = postURL.replace(" ", "%20");
        BackendAPIService sh = new BackendAPIService();

        System.out.println(":::::::::::::::::::post buying request URL:::::::::::::::::" + postURL);
        // Making a request to url and getting response
        String jsonStr = sh.makeServiceCall(postURL, BackendAPIService.POST);

        Log.d("Response: ", "> " + jsonStr);
        try {
            if (jsonStr != null) {

                jsonObj = new JSONObject(jsonStr);
                if (jsonObj.get("status").equals("success")) {
                    flag = 0;
                }

            } else {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

        } catch (JSONException e) {
            e.printStackTrace();
            System.out.println("::::::::::::::::::got an error::::::::::::");
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);
        Intent i;
        // Dismiss the progress dialog
        if (pDialog.isShowing())
            pDialog.dismiss();
        if (flag == 0) {
            Utils.showCustomeAlertValidation(BuyingreqActivity.this, "Request Posted", "Yehki", "OK");
            clearViews();

        } else {
            Toast.makeText(BuyingreqActivity.this, "Buying Request has not been posted", 0).show();
        }
        /**
         * Updating parsed JSON data into ListView
         * 
         * */

    }

}

void clearViews() {
    productName.setText("");
    productDesc.setText("");
    estOrderQty.setText("");
    expTime.setText("Expiration Time");
    proImg.setImageResource(R.drawable.noimage);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CAMERA_CAPTURE) { // for camera
        try {
            System.out.println("============= FILENAME :: " + fileName);
            if (new File(Const.DIR_USER + "/" + fileName).exists()) {
                performCrop();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (requestCode == 2) { // for crop image
        try {
            if (data != null) {
                Bundle extras = data.getExtras();
                Bitmap thePic = extras.getParcelable("data");

                Utils.createDirectoryAndSaveFile(thePic, Const.DIR_USER + "/" + fileName);

                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                thePic.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                byte[] imageBytes = baos.toByteArray();
                encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
                // pro_pic.setImageBitmap(thePic);
                @SuppressWarnings("deprecation")
                Drawable dra = (Drawable) new BitmapDrawable(thePic);
                proImg.setImageDrawable(dra);
                proImg.setScaleType(ScaleType.FIT_XY);

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (requestCode == PICK_FROM_GALLERY && resultCode == RESULT_OK) {

        if (data != null) {
            /*
             * fileName = Const.DIR_USER + "/" + "user_" +
             * Pref.getValue(ProfileActivity.this, Const.PREF_USER_ID, 0) +
             * "_" + System.currentTimeMillis() + ".png";
             */
            fileName = "user_" + Pref.getValue(BuyingreqActivity.this, Const.PREF_USER_ID, 0) + "_" + System.currentTimeMillis() + ".png";

            Bundle extras2 = data.getExtras();
            Bitmap photo = extras2.getParcelable("data");

            Utils.createDirectoryAndSaveFile(photo, Const.DIR_USER + "/" + fileName);

            String filePath = Const.DIR_USER + "/" + fileName;
            System.out.println("::::::::::::::::GALLERY PATH:::::::::::::" + filePath);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            photo.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            byte[] imageBytes = baos.toByteArray();
            encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
            ImageView picView = (ImageView) findViewById(R.id.iv_img);

            picView.setImageBitmap(photo);

        }

    }
    if (requestCode == 10) {
        if (resultCode == RESULT_OK) {
            id = data.getStringExtra("ID");
            name = data.getStringExtra("NAME");
            System.out.println("::::::::::::::::::On activity result:::::::::::" + id + "==========" + name);
            productCategory.setText(name);
        }
        if (resultCode == RESULT_CANCELED) {
            // Write your code if there's no result
        }
    }
}

private void performCrop() {
    try {

        System.out.println("============= AFTER FILENAME :: " + fileName);

        Intent cropIntent = new Intent("com.android.camera.action.CROP");
        imageUri = Uri.fromFile(new File(Const.DIR_USER + "/" + fileName));
        String ImagePath = imageUri.toString().trim();

        try {
            imageInFile = new FileInputStream(ImagePath);
            byte imageData[] = new byte[(int) ImagePath.length()];
            imageInFile.read(imageData);

            // Converting Image byte array into Base64 String
            imageDataString = encodeImage(imageData);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        cropIntent.setDataAndType(imageUri, "image/*");
        cropIntent.putExtra("crop", "true");
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        cropIntent.putExtra("outputX", 200);// 256
        cropIntent.putExtra("outputY", 200);

        cropIntent.putExtra("return-data", true);
        startActivityForResult(cropIntent, 2);
    }

    catch (ActivityNotFoundException anfe) {

        String errorMessage = "Whoops - your device doesn't support the crop action!";
        Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
        toast.show();
    }
}

/*
 * CONVERT THE IMAGE TO DATA..!!!
 */
public static String encodeImage(byte[] imageByteArray) {
    return Base64.encodeToString(imageByteArray, 1);
}
05-13 19:04:34.606: I/System.out(23172): :::::::::::::::::::post buying request URL:::::::::::::::::http://yehki.epagestore.in/app_api/buying_request.php?customer_id=41&product_name=juh7&category_id=4&expire_time=2014-07-13&detail_desc=uhuh&esti_ordr_qty=200&esti_ordr_qty_unit=1&filename=user__1399988051310.png&image=/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
05-13 19:04:34.606: I/System.out(23172): AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
05-13 19:04:34.606: I/System.out(23172): AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCACgAKADASIA
05-13 19:04:34.606: I/System.out(23172): AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
05-13 19:04:34.606: I/System.out(23172): AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
05-13 19:04:34.606: I/System.out(23172): ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
05-13 19:04:34.606: I/System.out(23172): p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
05-13 19:04:34.606: I/System.out(23172): AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx...and so one..!!!