Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8770219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:31:11+00:00 2026-06-13T17:31:11+00:00

Hello I Want to capture image by click a button and after the photo

  • 0

Hello I Want to capture image by click a button and after the photo was taken it will show on the screen and then click another button which will send that image to server. i tried it in many ways but i didn’t found any appropriate solution so please help me.

I am developing this in android 2.3.3

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
             Bitmap photo = (Bitmap) data.getExtras().get("data"); 
             imageView.setImageBitmap(photo);
             Intent intent= getIntent();
            System.out.println("image name=========================:: "+imageName);
            requestIntent.putExtra("imageName", imageName);
            startActivity(requestIntent);

        } else if (resultCode == RESULT_CANCELED) {
            // User cancelled the image capture
        } else {
            // Image capture failed, advise user
        }
    }
}

the image is not showing in that ImageView but stored in SdCard. And while am sending that image by calling another intent it shows me a error i.e 11-01 12:00:15.085: E/log_tag(9205): Error in http connection android.os.NetworkOnMainThreadException
and that intent code is.

public class PreviewAndSendImage extends Activity{

@SuppressLint("SdCardPath")
public void onCreate(Bundle savedInstanceState) {       
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button send=(Button) findViewById(R.id.sendToServer);
    send.setEnabled(true);
    send.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent intent= getIntent();
            String name=intent.getStringExtra("imageName");
            System.out.println("image name :::::::::::::::: +" +name);
            Bitmap bitmapOrg = BitmapFactory.decodeFile("/sdcard/pictures/"+name);
            ByteArrayOutputStream bao = new ByteArrayOutputStream();
            bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);
            byte [] ba = bao.toByteArray();

            String ba1=Base64.encodeBytes(ba);
            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("reqId", "40"));
            nameValuePairs.add(new BasicNameValuePair("image",ba1));    

            try{

                     HttpClient httpclient = new DefaultHttpClient();
                     HttpPost httppost = new HttpPost("http://192.168.0.115:8085/Dplus_EB/bill");
                     httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                     HttpResponse response = httpclient.execute(httppost);
                    //HttpEntity entity = response.getEntity();
                    //is = entity.getContent();
                     BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                      String line = "";
                      while ((line = rd.readLine()) != null) {
                          System.out.println("success----------------------------");
                          Toast.makeText(PreviewAndSendImage.this, "Status: "+line, Toast.LENGTH_LONG).show();
                      }
            }catch(Exception e){

                    Log.e("log_tag", "Error in http connection "+e.toString());

            }

        }
    });

}
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:31:12+00:00Added an answer on June 13, 2026 at 5:31 pm

    Please follow the simple steps below and you can easily achieve what you want:

    Step 1 : Make a class in your app that capture photo from camera and save it to your sd-card directory. See this Link, see also this discussion discussion.

    step 2 :Now make Android FTP client. See this link.

    step 3 : Now you can make many types of interaction with FTP server like changeDir, Upload files, Download file. See this Tutorial.

    It is simple but only condition is that you have to read some documents. Please accept and vote up my answer if you find it helpful. And also comment me if any link not worked. Thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On the click of a button, I want to capture a form's data and
Hello I want a button to hide until my last image view has been
Hello I want to read output of command which gives progress bar like output
Hello i want to replace the text in div when user click on it
Hello Guys! Using firefox plugins I can capture headers. I want to do it
Hello i want to extract links <a href=/portal/clients/show/entityId/2121 > and i want a regex
Hello i want to set the background for the combobox i have to another
Hello I want to create a table view like as following image There is
Hello I want to make an application which uses Multi-touch support. for multitouch i
Hello I want to know if is possible to modify a cube dimension in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.