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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:53:29+00:00 2026-05-26T16:53:29+00:00

Im using a camera application in android. I want to pass the byte data

  • 0

Im using a camera application in android. I want to pass the byte data from PictureCallback method to another activity and want to display it in that activity.

Camera.PictureCallback jpegCallback = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {


        }
    };

If anyone Knows about it, please help me..

  • 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-26T16:53:29+00:00Added an answer on May 26, 2026 at 4:53 pm

    You can do that with extras:

    Camera.PictureCallback jpegCallback = new PictureCallback() {
            public void onPictureTaken(byte[] data, Camera camera) {
                Intent i = new Intent(context, B.class);
    
                Bundle bundle = new Bundle();
                bundle.putByteArray("photo", data);
                i.putExtra(bundle );
                startActivity(i);
            }
    };
    

    and the on the B Activity:

    Bundle extras = getIntent().getExtras();
    byte[] photo = extras.getByteArray("photo");
    

    To show the image on the second activity, you must convert the byte[] into a bitmap and the assign it to a imageView:

    Bitmap bitmap  = decodeByteArray (photo, 0, photo.length);
    ImageView imgView = (ImageView)findViewById(R.id.preview);
    imgView.setImageBitmap(bitmap);
    

    I never tried to decode from byte[] to bitmap.. but you can find more information here.

    EDIT: @ss1271’s comment is right. According to this answer seems that there’s a limit of 500Kb. which means that if your image is big you should save it and pass the reference to the new activity like this:

    // A ACTIVITY
    
    Camera.PictureCallback jpegCallback = new PictureCallback() {
            public void onPictureTaken(byte[] data, Camera camera) {
                String fileName = "tempIMG.png";
                try {
                    FileOutputStream fileOutStream = openFileOutput(fileName, MODE_PRIVATE);
                    fileOutStream.write(data);
                    fileOutStream.close();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
                Intent i = new Intent(context, B.class);
    
                Bundle bundle = new Bundle();
                bundle.putExtra("photoPath", fileName);
                i.putExtra(bundle);
                startActivity(i);
            }
    };
    
    // B ACTIVITY
    
    Bundle extras = getIntent().getExtras();
    String photoPath = extras.getString("photoPath");
    File filePath = getFileStreamPath(photoPath);
    //And do whatever you want to do with the File
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In My Android Camera Application, I am using this code to get Select Image
I new in the android developing. I want to develop simple application that will
I am developing an application that needs to capture a barcode Image using Camera
i have problem using camera in my Android application i have a form for
I want my application to recognize barcodes taken by camera. Is it possible using
I'm developing an Android application that uses the camera and will run on Android
Hi guys I am using the following code to access Camera from my application
Hi I'm using this to open up the native android camera application Intent camera
i am trying to open camera from my android application and capture image, but
In my Direct3D application, the camera can be moved using the mouse or arrow

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.