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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:22:01+00:00 2026-06-18T12:22:01+00:00

I call this function: private void TakePhoto() { LogService.log(TAG, inTakePicture); Intent intent = new

  • 0

I call this function:

  private void TakePhoto() {
    LogService.log(TAG, "inTakePicture");
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/BlueSkyBio/media/", "test.jpg");

    outputFileUri = Uri.fromFile(file);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(intent, TAKE_PICTURE);

}

Which takes me on the next onActivityResult:

 public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == TAKE_PICTURE) {
        if(outputFileUri != null){
            LogService.log("MainFragment", outputFileUri.toString());
            String path = outputFileUri.toString();
            selectedVideoPath = path.substring(7);
            LogService.log("in take pic", "selectedImagePath: " + selectedVideoPath);
            Intent paintActivity = new Intent(getActivity(), PaintActivity.class);
            paintActivity.putExtra("selectedImagePath", selectedVideoPath);
            paintActivity.putExtra("isVideo", false);
            startActivity(paintActivity);
            ((FragmentActivity) getActivity()).finish();
        } else{
            //                Toast.makeText(getActivity(), "No picture taken", Toast.LENGTH_SHORT).show();
            Intent main = new Intent(getActivity(), FragmentActivity.class);
            startActivity(main);
            ((FragmentActivity) getActivity()).finish();
        }


    }

}

This works ok, but if i call the intent to take a picture, and then press the back button, if i already took a picture before, it will load that picture, if not, it will crash, because by pressing back, it will not take a picture. What can i do to escape this situation?

I have tried to test:

  if(data != null) // instead of:  if(outputFileUri != null){

But this will never enter the “else” part of the code.

  • 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-18T12:22:03+00:00Added an answer on June 18, 2026 at 12:22 pm

    use these conditions:

    private static final int CAMERA_PIC_REQUEST = 1337;  
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    
        if(requestCode==CAMERA_PIC_REQUEST && resultCode == RESULT_OK){
    
             log.d("something","something");          
        }
        else if (resultCode == Activity.RESULT_CANCELED) 
        {
            log.d("something","something");
        }
    

    }

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

Sidebar

Related Questions

arr=Array.new(3) arr[0]=5 arr[1]=3 arr[2]=2 These lines should call this function, https://github.com/ruby/ruby/blob/trunk/array.c#L568 according to this,
Take this example code private void test() { Label1.Text = Function 1 started.; function1();
I have a function like this: private void GetRSS(int start, int end) { for
I have to call a function on a button click event like this private
I have button call this code private void but_Click(object sender, EventArgs e) { Thread
I call this function from with my code-behind: DeleteFile(Server.MapPath(/) + sitemap_index.xml) Public Shared Function
So if I call this function: $(#item).text() on this HTML code: <div id=item> <pre><span
If I want to trigger an error in my interpreter I call this function:
I have this follow code in my javascript. I call this function when the
I have a UDF in sql server. I want to call this function at

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.