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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:40:06+00:00 2026-05-24T02:40:06+00:00

i am using following code for capturing the image in Android: String fileName =

  • 0

i am using following code for capturing the image in Android:

String fileName = "image.jpeg";
                //create parameters for Intent with filename
                ContentValues values = new ContentValues();
                values.put(MediaStore.Images.Media.TITLE, fileName);
                values.put(MediaStore.Images.Media.DESCRIPTION,"Image captured by camera");
                //imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)
                imageUri = getContentResolver().insert(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
                //create new Intent
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
                startActivityForResult(intent, CAMERA_PIC_REQUEST); 

After capturing the image, i am using following code to get image:

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
        {
            super.onActivityResult(requestCode, resultCode, data);
                            if( requestCode == CAMERA_PIC_REQUEST)
                {
                    if(resultCode == Activity.RESULT_OK)
                    {
                        if(imageUri == null)
                            imageUri = data.getData();
                        String filePath = getPath(imageUri);
                        UploadContentToServer(filePath, "image.jpeg");
                        //getBytesFromFile(filePath);
                    }
                }
}

It works fine in all devices except HTC in landscape mode.

I am using portrait mode in my app. But when i capture a image in landscape mode in my HTC,i am getting imageUri null.
How to resolve this issue, it is only in HTC devices.

  • 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-24T02:40:06+00:00Added an answer on May 24, 2026 at 2:40 am

    I had the same issue on my galaxy s2 when trying to capture images with the camera. Try specifying the real path in the intent and then get the path down in your onActivityResult. Extracting the uri directly from the Intent data didnt work for me in image capture either.

    Here is an example of what I mean:

     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
     fileName = dateFormat.format(new Date()) + ".jpg";
     File photo = new File(Environment.getExternalStorageDirectory(), fileName);
     Intent cameraintent = new Intent("android.media.action.IMAGE_CAPTURE");
     cameraintent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
     imageURICamera = Uri.fromFile(photo);
     startActivityForResult(cameraintent, 1);
    

    And now getting the foto again in onActivityResult:

     realPath = Environment.getExternalStorageDirectory() + "/" + fileName; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I am currently using the following code to create a web request: Dim myRequest
I'm capturing the window.onbeforeunload event using the following code: window.onbeforeunload = function (evt) {
I am using following code to draw scaled image in PaintListener. e.gc.drawImage(image, 0, 0,
I'm using the following code to query a database from my jsp, but I'd
I've been using the following code to open Office Documents, PDF, etc. on my
I am using following PHP code to connect to MS Access database: $odb_conn =
I'm using the following code within the JCProperty class to retrieve data from a
I'm using the following code, using the SharpZipLib library, to add files to a
I'm using the following code to loop through a directory to print out the

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.