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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:37:34+00:00 2026-06-11T02:37:34+00:00

The following code downloads a image from Amazon S3 into the device, and then

  • 0

The following code downloads a image from Amazon S3 into the device, and then I try to load the image in gallery.
My issue is different for the Device (Nexus 7) and the emulator.
My code below is a cumulation of reading through stackoverflow answers.

1) In the emulator DDMS, I find the file test.jpg in the device under /data/data/myprojectname/file/test.jpg The size of the file is correct.
However, it says “Unfortunately camera has stopped working” when I try to load the image using the intent method below.

2) For the Nexus 7, gallery simply shows up with no image. I can’t really find the image “test.jpg” using Astro file manager, why is this so?

Also, why would the emulator and the device act differently?

This is driving me crazy, thanks in advance for your help.

Pier.

showInGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                // Ensure that the image will be treated as such.
                ResponseHeaderOverrides override = new ResponseHeaderOverrides();
                override.setContentType( "image/jpeg" );


                // Generate the presigned URL.
                Date expirationDate = new Date( System.currentTimeMillis() + 3600000 );   // Added an hour's worth of milliseconds to the current time.
                GeneratePresignedUrlRequest urlRequest = new GeneratePresignedUrlRequest( Constants.getPictureBucket(), Constants.PICTURE_NAME );
                urlRequest.setExpiration( expirationDate );
                urlRequest.setResponseHeaders( override );

                URL url = s3Client.generatePresignedUrl( urlRequest );
                /* Open a connection to that URL. */
                File file = new File(PATH + Constants.PICTURE_NAME);
                URLConnection ucon = url.openConnection();

                /*
                * Define InputStreams to read from the URLConnection.
                */
                InputStream is = ucon.getInputStream();
                BufferedInputStream bis = new BufferedInputStream(is);

                /*
                * Read bytes to the Buffer until there is nothing more to read(-1).
                */
                ByteArrayBuffer baf = new ByteArrayBuffer(50);
                int current = 0;
                while ((current = bis.read()) != -1) {
                    baf.append((byte) current);
                }

                /* Convert the Bytes read to a String. */
                String fileName = "test.jpg";
                //FileOutputStream fos = new FileOutputStream(fileName);
                FileOutputStream fos = openFileOutput(fileName, Context.MODE_PRIVATE);
                fos.write(baf.toByteArray());
                fos.close();

                /* read the file */
                File filePath = getFileStreamPath(fileName);

                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse(filePath.toString()), "image/*");
                startActivity(intent);


            }
            catch ( Exception exception ) {
                S3UploaderActivity.this.displayAlert( "Browser Failure", exception.getMessage() );
            }
        }
    });
  • 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-11T02:37:35+00:00Added an answer on June 11, 2026 at 2:37 am

    You should consider using lazyloading instead,
    take a look at this project:

    https://github.com/thest1/LazyList

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

Sidebar

Related Questions

I am try to download image files from url from the following code, but
I am using following code to load public shared images from google drive to
I am using the following to code make an image gallery, but I would
I have the following code to download an image: imageRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:magazineItem.contentURL]];
I used the following code to download/save an image and open it later, but
I'm using the following code to download a pdf from a list of pdfs
I'm trying to use Qt to download the html code from the following url:
Android:How to display images from the web in a ListView?I have the following code
I am following this book Pro.ASP.NET.MVC.3.Framework from Adam Freeman. So I download the code
I want to load an image from url on a button click & to

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.