2017-04-03 14 views
-2

Ich möchte URI eines Bildes von URL, die auf dem Server gespeichert ist. Ich habe das versucht. uri = neuer URI ("http://www.google.com/");Wie bekomme ich Uri von einem Bild von der URL?

und

ri uri = Uri.parse ("http://www.facebook.com");

+0

Weder http://www.google.com/ noch http://www.facebook.com/ gelten Bild URIs –

+0

Was erstreckt, falsch mit deinem Code? Du hast es nicht erzählt. Und das ist in der Tat keine Bild-URL. Aber das ist nicht so wichtig. – greenapps

Antwort

0

Möchten Sie die Bilddatei in Ihrem Gerät speichern oder was genau Sie wollen.

ImageView.setImageURI (Uri.parse ("http://www.facebook.com"));

oder Sie müssen es in Ihrem Telefon speichern.

// download AsyncTask private Klasse download AsyncTask {

@Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
     // Create a progressdialog 
     mProgressDialog = new ProgressDialog(MainActivity.this); 
     // Set progressdialog title 
     mProgressDialog.setTitle("Download Image Tutorial"); 
     // Set progressdialog message 
     mProgressDialog.setMessage("Loading..."); 
     mProgressDialog.setIndeterminate(false); 
     // Show progressdialog 
     mProgressDialog.show(); 
    } 

    @Override 
    protected Bitmap doInBackground(String... URL) { 

     String imageURL = URL[0]; 

     Bitmap bitmap = null; 
     try { 
      // Download Image from URL 
      InputStream input = new java.net.URL(imageURL).openStream(); 
      // Decode Bitmap 
      bitmap = BitmapFactory.decodeStream(input); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
     return bitmap; 
    } 

    @Override 
    protected void onPostExecute(Bitmap result) { 
     // Set the bitmap into ImageView 
     image.setImageBitmap(result); 
     // Close progressdialog 
     mProgressDialog.dismiss(); 
    } 
} 
+0

Ich möchte dieses Bild mit anderen Apps teilen –

+0

Ich verstehe nicht, was du machst ..! Sie möchten die Bildanzeige in App oder das Bild wie Whats App zu einem anderen Völker wie teilen –