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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:13:10+00:00 2026-06-11T19:13:10+00:00

I have a method in my activity that starts a image_capture event public static

  • 0

I have a method in my activity that starts a image_capture event

    public static void takePhoto(boolean fullSize) {

    if(isIntentAvailable(mActivity.getApplicationContext(), MediaStore.ACTION_IMAGE_CAPTURE)){
        mActivity.startActivityForResult(new Intent(
                MediaStore.ACTION_IMAGE_CAPTURE), CAPTURE_IMAGE);
    }
    else{
        Toast.makeText(mActivity.getApplicationContext(), "Geen camera beschikbaar", Toast.LENGTH_SHORT).show();
    }
}

public static boolean isIntentAvailable(Context context, String action) {
    final PackageManager packageManager = context.getPackageManager();
    final Intent intent = new Intent(action);
    List<ResolveInfo> list =
            packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

When the user has taken a picture, I want to get the bytes from the photo and broadcast those bytes.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_CANCELED) {

        case CAPTURE_IMAGE:
                byte[] photoBytes = null;

                if (data != null) {
                    Bitmap b = (Bitmap) data.getExtras().get("data");
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    b.compress(Bitmap.CompressFormat.PNG, 100, stream);
                    photoBytes = stream.toByteArray();

                    Toast.makeText(getApplicationContext(), "Foto wordt geupload..", Toast.LENGTH_SHORT).show();
                    Log.d("ShowScreenActivity", Integer.toString(photoBytes.length));

                    // Send bytearray back to server
                    BroadcastSender.sendPicture(photoBytes);
                }
                else
                    Log.d("ShowScreenActivity", "Data in intent is empty");

            break;
        }
    }
}

Everything works fine, but the image is also stored in the gallery on the device.
How can I prevent this or what do I do wrong?

  • 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-11T19:13:11+00:00Added an answer on June 11, 2026 at 7:13 pm

    Your image is saved to the gallery, because that is the default behaviour. To override this, you need to specify a different target folder to save your image (in the intent calling the camera), and put a .nomedia file in the folder

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

Sidebar

Related Questions

I have a method that I need to run when the activity starts. I've
I have an activity that launches another activity with startActivityForResult method. I would like
I have noticed that when using actionBar.setSelectedNavigationItem(x) in the onCreate() method of my Activity,
I have an Activity that starts and binds to a Service . I then
I have an android app that has mutliple activities The first main activity starts
I have an Activity A that starts Activity B: activityA.startActivityForResult(new Intent(activityA, B.class), REQUESTCODE_B); At
I have the following code in an Activity that starts a dialog for a
I have a view subclass that starts from activity subclass like that: this.setContentView(instanceOfMyView); In
I have an activity that starts after a certain time. Once this activity starts,
I have a menu button that starts a new activity and when it's done

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.