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

  • Home
  • SEARCH
  • 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 7767069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:35:02+00:00 2026-06-01T15:35:02+00:00

In my application, I’m trying to make it so the User can press a

  • 0

In my application, I’m trying to make it so the User can press a button, which will allow them to take a picture using the stock camera application on their phone.

I am following the guide to using an external Camera app to capture images that I can use in my own app from the Android Developers Guide (http://developer.android.com/guide/topics/media/camera.html#intent-receive)

I’m having trouble with the onActivityResult() method, it apparently takes in 3 parameters

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
        if(resultCode == RESULT_OK) {
            Log.w("borre","Image saved to:\n" + data.getData());
        } else if (resultCode == RESULT_CANCELED) {
            // User cancelled the image capture
        } else {
            // Image capture failed, advise user
        }
    }
}

But at the moment, the data Intent is coming back as null, so calling any methods on the Intent parameter throws a NullPointerException

Here’s the code I’m using to call up the Camera application (It’s basically the same as the code in the guide)

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

Uri fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

Has anyone had this problem or knows why this Intent is coming back as null?

  • 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-01T15:35:03+00:00Added an answer on June 1, 2026 at 3:35 pm

    your are getting data part null bez you are not setting intent.setDataAndType() when you are starting Acitivty.like

        public static final String IMAGE_UNSPECIFIED = "image/*"; 
        Intent intent = new Intent(Intent.ACTION_PICK, null);  
        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_UNSPECIFIED);  
        startActivityForResult(intent, 3);  
    
        protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
        if (resultCode == 0)  
           return; 
        if (requestCode == 2) {  
           Uri uri=data.getData();  //YOU GET DATA HERE
            }  
    //OR
    if (requestCode == 3) {  
     Bundle extras = data.getExtras();  
     if (extras != null) {  
     Bitmap photo = extras.getParcelable("data");  
     ByteArrayOutputStream stream = new ByteArrayOutputStream();  
     photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);// (0 - 100)????  
     imageView.setImageBitmap(photo);  
      }  
    }  
    

    or in your case getting image path use:

    if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {  
         //pic path
          File picture = new File(Environment.getExternalStorageDirectory() + "/temp.jpg");  
       } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application : I am working on one mid-large size application which will be used
Application: This is a workshop proposal system for a conference. A user can create
The application crashes on the row: [uids addObject:user.uid]; Who can tell why??
Application works fine. I can access everything in debug except for an Array Adapter
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
application = webapp.WSGIApplication( [(r'/main/profile/([a-f0-9]{40})', ProfileHandler)], debug=True) The regex in the above parameter will not
Application frameworks such as DotNetNuke, Eclipse, Websphere and so forth are available today which
Application is asp.net MVC. I want to put a textbox for date using mask.
application for project .....csproj is not installed. Make sure the application for the project
APPLICATION and ENVIRONMENT Java EE / JSF2.0 / JPA enterprise application, which contains a

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.