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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:31:06+00:00 2026-05-31T05:31:06+00:00

first post so be nice :) My problem is that I have a class

  • 0

first post so be nice 🙂

My problem is that I have a class to open my phone Camera. However, if i press the back button on my phone, the app will crash.

Is there any way to prevent this? maybe just disable the back button?

Any help would be appreciated

This is the code I call to open the camera.

    btnpicture.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityIfNeeded(cameraIntent, CAMERA_REQUEST);
        }
    });

EDIT: This problem also occurs when I have another button to open the Gallery. The app just crashed if the Back button is pressed.

    btnsdpic.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent gallery = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            startActivityIfNeeded(gallery, SELECT_IMAGE);
        }
    });

Thanks Guys

Hemm.

  • 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-31T05:31:07+00:00Added an answer on May 31, 2026 at 5:31 am

    Try:

     Intent gallery = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
     startActivityForResult(camera, SELECT_IMAGE);
    

    And:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    
         if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
           if (resultCode == RESULT_OK) {
            Toast.makeText(this, "Image Caputred", Toast.LENGTH_SHORT).show();
         } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(this, "Image was not Caputred", Toast.LENGTH_SHORT).show();
         } else {
            Toast.makeText(this, "Image was not Caputred", Toast.LENGTH_SHORT).show();
         }
        }    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post here. I have a problem. I need to take
This is my first post, so please be nice :) I have a question
Post Update: I have tracked down the problem at the command ExecuteNonQuery. That's the
first post, so play nice! I have a fairly basic question about Python dictionaries.
this is my first post. I have a huge problem which make me headaches.
First post, so here goes. I'm writing a script that does intelligent search and
I don't have nice short code examples to display with this post. I'm running
This is my first post on here so be nice :) I am new
This is my first post and I have to admit, I am terrible at
First, sorry for my bad english, I'm French. Here the problem : I have

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.