Ich versuche mit diesem Code und es funktioniert nicht. Wie kann ich dieses Bild herunterladen und anzeigen? Wie man ein php Bild in der Bildansicht zeigt?
mein Java-Code
private ImageView iv;
private Bitmap bitmap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_showprofile);
iv = (ImageView) findViewById(R.id.virus);
bitmap = getBitmapFromURL("http://getbloodbd.org/image.php?no=4");
iv.setImageBitmap(bitmap);}
public Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
return null;
}
}
und mein xml-Code ist
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="org.getbloodbd.getbloodbd.ShowprofileActivity"
tools:showIn="@layout/app_bar_showprofile">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/virus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
und mein PHP-Code ist und in webview Methode ist es gut funktionieren, aber die Bildansicht nicht funktioniert, aber Ich brauche Bildansichtsmethode.
<?php include 'config.php';header("Content-type: image/gif");$no=$_GET['no']; $dn = mysql_query('select image from images where no="'.$no.'"'); $dnn = mysql_fetch_array($dn); $data = $dnn['image'];echo base64_decode($data);?>
Wie löst man es?
geben Sie die vollständige URL –