Reputation: 151
I have spent days to try and get this to work but still no luck.
My problem is that the url redirects to a https
version for some reason
So lets say this is the image url:
http://api.androidhive.info/images/sample.jpg
for some reason the image redirects to https like to:
https://api.androidhive.info/images/sample.jpg
Since my site does not have https it gives:
"This site can’t be reached"
and then no image is downloaded
I've followed this tutorial link
I am using Picasso to load the image all the https url from youtube work from but when i call a url that has no https then it does not work
This is what version of android I am using
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.example"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
I have no idea what to do any help will be great.
Upvotes: 1
Views: 1135
Reputation: 1368
Following is just a work around or hack you can do,
In the callback of Picasso do this:
//this is the url which is having https
String url = "https://api.androidhive.info/images/sample.jpg";
//in callback of picasso which is overriden when some error occurs do this steps
String newUrl = url.replace("https", "http");
Picasso.with(context)
.load(newUrl)
.into(imageView);
This is just a way around
If this way around is not working follow this link
what JakeWharton solution for this
Upvotes: 2