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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:55:10+00:00 2026-06-14T14:55:10+00:00

In my app, there is an ImageView that display an image from a URL.

  • 0

In my app, there is an ImageView that display an image from a URL.

I download the image using this method:

        Bitmap bitmap=null;
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        conn.setInstanceFollowRedirects(true);
        InputStream is=conn.getInputStream();
        OutputStream os = new FileOutputStream(f);
        Utils.CopyStream(is, os);
        os.close();
        bitmap = decodeFile(f);
        return bitmap;

This works only with URLs that has numbers or english letters and doesn’t work with any other chars (like spaces):

Good URL: http://site.com/images/image.png

Bad URL: http://site.com/images/image 1.png

I tried to chage the URL encoding (URLEncoder.encode), but it changes the whole URL (incliding slashes, ect…).

Do I need to replace some chars after the encoding? or maybe there is a better way?

Thanks 🙂

  • 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-14T14:55:11+00:00Added an answer on June 14, 2026 at 2:55 pm

    “Url encoding in Android“

    You don’t encode the entire URL, only parts of it that come from
    “unreliable sources”. -yanchenko

    String query = URLEncoder.encode("apples oranges", "utf-8");
    String url = "https://stackoverflow.com/search?q=" + query;
    

    This is fine if you are just dealing with a specific part of a URL and
    you know how to construct or reconstruct the URL. For a more general
    approach which can handle any url string, see my answer below. – Craig
    B

    String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
    URL url = new URL(urlStr);
    URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
    url = uri.toURL();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that pulls an image from an url and displays it
So I'm using Bitmap.createScaledBitmap to scale and display in an imageview files that i
I have a query in my android app that pulls all image paths from
There's an ImageView in my app with a drawable that can be changed by
In my app there is requirement that..I have 6 buttons in a nib, when
Hello i am using SocializeActionBar for my app there i have multiple links. I
I'm coding an app that works much like Apple's Weather.app: There's a UIPageControl at
I understood that in order to use cookies inside of phonegap native app there
in my app, i have large images, i display it in an image view
I've an app that distorts a circle on a bitmap with a fisheye distortion.

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.