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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:38:31+00:00 2026-06-06T08:38:31+00:00

In my application it captures some images when I click on a button. When

  • 0

In my application it captures some images when I click on a button. When I click this button first time then camera Intent open after that onActivityResult is called by the application and then onResume method called by the application every thing works fine. But when I click second time on the button then camera intent is called by the application but after that application call onCreate method then onActivityResult method. I don’t knot why onCreate method is called by the program. And because of this my program throw some error.

Code(when button is clicked which call addPhoto method):

protected void addPhoto() {
System.out.println("*** addPhoto() ***");

    Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    out1 = Environment.getExternalStorageDirectory(); // out1 is initialized as File out1 = null;
    photoDateString = new DateClass().getCurrentDateAndTime();//this line give current date and time as photo name
    out1 = new File(out, "xxx/images/" + photoDateString + ".jpg");
    i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(out1));
    startActivityForResult(i, CAMERA_REQUEST);

 System.out.println("*** End of addPhoto() ***");
}

Code(onActivityResult):

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    System.out.println("*** onActivityResult() ***");

    if (out1 != null && out1.exists()) { 
        // some code
    }
    //some code
    System.out.println("*** End of onActivityResult() ***");
}

Because program calls onCreate method before onActivityResult its throw error for the line if (out1 != null && out1.exists()) {

I don’t know what I need to do .

Error Message:

java.lang.RuntimeException: Unable to resume activity {com.pxxl.android.lxxxy/com.pxxl.android.lxxxy.FirstActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=null} to activity {com.pxxl.android.lxxxy/com.pxxl.android.lxxxy.FirstActivity}: java.lang.NullPointerException
  • 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-06T08:38:34+00:00Added an answer on June 6, 2026 at 8:38 am

    It looks like you don’t save out1 on activity life-cycle callbacks. Use onSaveInstanceState() and onRestoreInstanceState() to save/restore its value.

    Here is more detailed explanation on activity state handling: Saving Activity State.

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

Sidebar

Related Questions

I'm currently writing a application that needs to capture some images. I start the
I have an application written in C that captures an image via webcam,does some
This is a Windows Forms application. I have a function which captures some mouse
I implemented one application in that application one button is there. if you click
I have an application that captures keystrokes. But i have read a little bit
We have an application that will capture different images from users and make them
I am trying to implement Camera application in android,and i got some code from
My iphone application captures the realtime data from camera using AVFoundation's AVCaptureSession. I'm able
I'm developing an application just for fun that consists of capturing images from a
I'm due to work on a small application that captures audio from the Mac's

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.