1
@Override
    protected Drawable doInBackground(String... params) {
        try{
            String url = params[0].replace("\\", "");
            Log.v("before", params[0]);
            Log.v("after", url);
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
        }catch (Exception e) {
            Log.e("Image Error", e.toString());
            return null;
        }
    }

7-07 22:02:03.282: before(21811): "https://s3-sa-east-1.amazonaws.com/inradar.media/uploads/ads/ad-60cd15be59b21725e45c5cf388065527.jpg"

07-07 22:02:03.282: after(21811): "https://s3-sa-east-1.amazonaws.com/inradar.media/uploads/ads/ad-60cd15be59b21725e45c5cf388065527.jpg"

07-07 22:02:03.282: Image Error(21811): java.net.MalformedURLException: Protocol not found: "https://s3-sa-east-1.amazonaws.com/inradar.media/uploads/ads/ad-60cd15be59b21725e45c5cf388065527.jpg"

10
  • 4
    Are the quotes part of the string or part of the log? Commented Jul 8, 2014 at 1:12
  • I'm not sure of that. I tried your url with quotes and I got the same exception. Commented Jul 8, 2014 at 1:17
  • @SotiriosDelimanolis If you hardcode it, it works. It might be something with the string escaping maybe. Commented Jul 8, 2014 at 1:19
  • 1
    @Patrick Right. So escaping characters in Strings is only important for String literals, that is string values hardcoded in the source code. Escape characters are removed (converted to a value) at runtime. The value in the logs is a String in memory. It appears to contain leading and ending quotation marks ". This will cause the URL parser to fail. Commented Jul 8, 2014 at 1:25
  • 1
    @Patrick The String literal (ie. in source code) String url = "\"http:\""; has the String value "http:" at runtime. If your question refers to something like a JSON array ["value1", "value2"], the answer depends on the parser. A proper parser will determine that the elements are JSON Strings and produce two String objects in an array with the values value1 and value2. Commented Jul 8, 2014 at 1:30

1 Answer 1

3

I don't know of any logger that will add enclosing quotes to a given log message. As such, I'm going to assume that your url String is literally

"https://s3-sa-east-1.amazonaws.com/inradar.media/uploads/ads/ad-60cd15be59b21725e45c5cf388065527.jpg"

The URL constructor cannot parse that value. Get rid of the leading and trailing quotation marks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.