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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:54+00:00 2026-05-23T11:02:54+00:00

If I have multiple buttons on a view to call camera intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE) and

  • 0

If I have multiple buttons on a view to call camera intent (android.provider.MediaStore.ACTION_IMAGE_CAPTURE) and a ImageView for the preview of each image and I need to know which button called it in onActivityResult so I know which corresponding preview to use how do I pass an identifying variable? Below is current code that only works with one image.

Picture button:

final ImageButton cameraTakePhotoButton = (ImageButton) photoPromptOption.findViewById(R.id.cameraTakePhotoButton);

cameraTakePhotoButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
    }
});

onActivityResult:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (resultCode == RESULT_OK) {
        if(requestCode == CAMERA_PIC_REQUEST) {
            Bitmap thumbnail = (Bitmap) data.getExtras().get("data");  
            final ImageView questionPhotoResult = (ImageView) findViewById(R.id.questionPhotoResult);
            questionPhotoResult.setImageBitmap(thumbnail);
        } 
    }
} 
  • 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-23T11:02:55+00:00Added an answer on May 23, 2026 at 11:02 am

    Ended up using a ListView and custom adapter then having it iterate over an ArrayList with objects of class Photo… I update the Bitmap (thumbnail) property for the Photo objects when I take the picture then refresh the ListView. This method works very well.

    photoListView.setAdapter(new ArrayAdapter<Photo>(this, R.layout.photo_list_item, photosList) {
         @Override
         public View getView(final int position, View convertView, final ViewGroup parent) {
    
                  View row = null;
    
                  final Photo thisPhoto = getItem(position);
    
                  if (null == convertView) {
                       LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                       row = inflater.inflate(R.layout.photo_list_item, null);
                   } else {
                       row = convertView;
                   }
    
                   photoPreview.setOnClickListener(new View.OnClickListener() {
                       public void onClick(View view) {
    
                            File photoDirectory = new File(Environment.getExternalStorageDirectory()+"/Pictures/appName");
    
                            if(!photoDirectory.isDirectory()) {
                                 photoDirectory.mkdir();
                            }
    
                            File photo = new File(Environment.getExternalStorageDirectory()+"/Pictures/appName/", thisPhoto.getId()+"_photo.jpg");
                            CameraHandlerSingleton.setPictureUri(Uri.fromFile(photo));
                            CameraHandlerSingleton.setPhotoId(thisPhoto.getId());
    
                            Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
                            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
                            startActivityForResult(intent, CAMERA_PIC_REQUEST);
    
                        }
                    });
    
                    return row;
    
                }
    
            });
    

    Then my onActivityResult:

     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == RESULT_OK) {
    
            if(requestCode == CAMERA_PIC_REQUEST) {  
    
                Uri selectedImage = CameraHandlerSingleton.getPictureUri();
                String photoId = CameraHandlerSingleton.getPhotoId();
    
                getContentResolver().notifyChange(selectedImage, null);
                ContentResolver cr = getContentResolver();
    
                Bitmap thumbnail;
    
                try {
                    thumbnail = Bitmap.createScaledBitmap(android.provider.MediaStore.Images.Media.getBitmap(cr, selectedImage), 300, 200, true);
                    p.setThumbnail(thumbnail);
                    p.setTaken(true);
                } catch(FileNotFoundException e) {
                    Toast.makeText(this, "Picture not found.", Toast.LENGTH_SHORT).show();
                    e.printStackTrace();
                } catch(IOException e) {
                    Toast.makeText(this, "Failed to load.", Toast.LENGTH_SHORT).show();
                    Log.e("Camera", e.toString());
                } catch(Exception e) {
                    Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
                    Log.e("Camera Exception", e.toString());
                    e.printStackTrace();
                }
    
                startActivity(getIntent());
                finish();
    
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Razor view with multiple buttons. I only want validation to occur
I have an android ListActivity that creates multiple buttons (from a database source) via
I have multiple buttons on the same activity each invoking the method guessMade() when
Multiple sites have buttons where you can tweet, digg, etc. On this page you'll
I have a form on an HTML page with multiple submit buttons that perform
I have an image sprite of sorts with multiple frames for 1 button. I'm
I have a gridview with multiple rows, each has a Update button and I
i have a form in which there can be multiple radio buttons generated dynamically
I have created an application with multiple views. I have my main view (ViewController.h)
let's say I'd like to have an image view in my app with zoom

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.