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 4622924
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:54:44+00:00 2026-05-22T02:54:44+00:00

Possible Duplicate: Calling camera from an activity, capturing an image and uploading to a

  • 0

Possible Duplicate:
Calling camera from an activity, capturing an image and uploading to a server

I need to build an application that will start the camera, take a photo, save that phto to the sdcard, and then upload this photo to a .net server without altering it’s quality, any one got an idea?

  • 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-05-22T02:54:45+00:00Added an answer on May 22, 2026 at 2:54 am

    you already wrote the solution ^^ To start the camera app use:

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
        captured_image = System.currentTimeMillis() + ".jpg";
        File file = new File(Environment.getExternalStorageDirectory(), captured_image); 
        captured_image = file.getAbsolutePath();
        Uri outputFileUri = Uri.fromFile(file); 
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); 
        intent.putExtra("return-data", true);
        ((Activity) GlobalVars.main_ctx).startActivityForResult(intent, RES_IMAGE_CAPTURE); 
    

    Then you need a ActivityResulListener Like:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        switch (requestCode) { 
            case RES_IMAGE_CAPTURE: 
    
                Log.i( "MakeMachine", "resultCode: " + resultCode );
                switch( resultCode )
                {
                    case 0:
                        Log.i( "MakeMachine", "User cancelled" );
                        break;
                    case -1:
                        //image storead, now load it in the web
                        break;
                    }
                break;
    
        }   
    }
    

    After storing the Picture you have to perform a Post Request to load the picture in the web, you need script wich is copying the file to the server, maybe asp.net and than you only have to perform the Request. I only have a code for https Requests with credentials, using a External Libary from appache, this might be a little bit too complicated, but I’m sure you will finde a code here, otherwise my solution looks like:

    public static boolean upload_image(String url, List<NameValuePair> nameValuePairs,String encoding) {
    
        DefaultHttpClient http = new DefaultHttpClient();
            SSLSocketFactory ssl =  (SSLSocketFactory)http.getConnectionManager().getSchemeRegistry().getScheme( "https" ).getSocketFactory(); 
            ssl.setHostnameVerifier( SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER );
            final String username = "username";
            final String password = "password";
            UsernamePasswordCredentials c = new UsernamePasswordCredentials(username,password);
            BasicCredentialsProvider cP = new BasicCredentialsProvider(); 
            cP.setCredentials(AuthScope.ANY, c); 
            http.setCredentialsProvider(cP);
            HttpResponse res;
            try {
                HttpPost httpost = new HttpPost(url);
                MultipartEntity entity = new MultipartEntity(HttpMultipartMode.STRICT); 
    
                for(int index=0; index < nameValuePairs.size(); index++) { 
                    ContentBody cb;
                    if(nameValuePairs.get(index).getName().equalsIgnoreCase("File")) { 
                        File file = new File(nameValuePairs.get(index).getValue());
                        FileBody isb = new FileBody(file,"application/*");
                        entity.addPart(nameValuePairs.get(index).getName(), isb);
                    } else { 
                        // Normal string data 
                        cb =  new StringBody(nameValuePairs.get(index).getValue(),"", null);
                        entity.addPart(nameValuePairs.get(index).getName(),cb); 
                    } 
                } 
    
    
                httpost.setEntity(entity);
                res = http.execute(httpost);
    
                InputStream is = res.getEntity().getContent();
                BufferedInputStream bis = new BufferedInputStream(is);
                ByteArrayBuffer baf = new ByteArrayBuffer(50);
                int current = 0;
                while((current = bis.read()) != -1){
                      baf.append((byte)current);
                 }
                res = null;
                httpost = null;
                String ret = new String(baf.toByteArray(),encoding);
                GlobalVars.LastError = ret;
                return  true;
               } 
            catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                return true;
            } 
            catch (IOException e) {
                // TODO Auto-generated catch block
                return true;
            } 
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Calling a webservice that uses ISO-8859-1 encoding from WCF I am trying
Possible Duplicate: Calling Python from Objective-C I'm a long-time Python programmer and short-time Cocoa
Possible Duplicate: C++ virtual function from constructor Calling virtual functions inside constructors This question
Possible Duplicate: Remove from the array elements that are repeated. in Ruby I would
Possible Duplicate: Calling a function from a string with the function's name in Python
Possible Duplicate: Calling a Function From a String With the Function's Name in Ruby
Possible Duplicate: Problem calling a Local HTML File from XCode I am using the
Possible Duplicate: How do malloc() and free() work? I read somewhere that calling free
Possible Duplicate: Calling ActionScript 3 function from C# i have a project which is
Possible Duplicate: How do you send email from a Java app using Gmail? How

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.