I want to fill an ImageView with an image saved on my localhost. I can display it in a browser fine but it doesn't get displayed in my ImageView.
PHP script to display image:
<?php
include('connect_db.php');
$id = $_GET['id'];
$path = 'Profile_Images/'.$id.'.jpg';
echo '<img src='.$path.' border=0>';
?>
Here is my android code to download an image from a URL:
URL url;
try {
url = new URL("http://192.168.1.13/get_profile_image.php?id=145");
new DownloadImage(this).execute(url);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void imageDownloaded(final Bitmap downloadedImage) {
runOnUiThread(new Runnable() {
public void run() {
ImageView imageView = (ImageView)findViewById(R.id.imageView);
imageView.setImageBitmap(downloadedImage);
}
});
}
When I put the URL to some other image it works fine but mine never gets loaded, any ideas?
Also, the following code works but I have a feeling its bad practice..
URL url;
try {
url = new URL("http://192.168.1.13/Profile_Images/145.jpg");
new DownloadImage(this).execute(url);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Where 145 would be a variable.
Edit
Any reasons for the down-votes would be appreciated!