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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:55:35+00:00 2026-05-25T13:55:35+00:00

I had a class that access the native camera to take picture. After the

  • 0

I had a class that access the native camera to take picture. After the picture had been taken, it will be save in a folder and that picture will be display in a new activity.

The problem is, i try to the get the data i put into the intent after the picture had been taken but it always says that the intent is null.pointer.exception. Below is my class, anyone please help me.

import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

 public class CameraTestActivity extends Activity {
Button start;
final int TAKE_PICTURE = 2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    start = (Button)findViewById(R.id.startButton);

    start.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            File file = new File(Environment.getExternalStorageDirectory().toString() + "/testImage/" + "toBeUpload.jpg");
            Uri imageUri = Uri.fromFile(file);


            Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
            cameraIntent.putExtra("path", imageUri.toString());
            startActivityForResult(cameraIntent,TAKE_PICTURE);

        }
    });
}

protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
    super.onActivityResult(requestCode, resultCode, intent);
    if(resultCode == RESULT_OK)
    {
        if(requestCode == TAKE_PICTURE)
        {
            /*ERRROR OCCUR HERE*/
            Bundle extras = intent.getExtras();
        }
    }
}
}
  • 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-25T13:55:36+00:00Added an answer on May 25, 2026 at 1:55 pm

    Rich and userSeven7s are right, but it’s rather besides the point in your particular case: you don’t actually need the Intent’s return data for the photo chooser (exception: some buggy very old phones only write a thumbnail in the extras and don’t actually write an image to the path you specified, but that’s another story) — just look for the image written to the URI you passed the intent originally.

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

Sidebar

Related Questions

Previously, I had a class that wrapped an internal System.Collections.Generic.List<Item> (where Item is a
I have a class that had an inline member, but I later decided that
I had a winforms C# class that internally was looking up a file.. to
I'm working on a class assignment that started small, so I had it all
I have an application that uses CoreData. I previously had a class named Marker
I had some decryption code (using wincrypt.h ) that lived within my FileReader.cpp class.
I had a function like this, that wasn't within a class: // Gets the
I updated my User class, and now whenever someone that had the old version
I have a class that needs access to two other classes. Signin needs access
I have created a class that I've been using as the storage for all

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.