2017-04-03 69 views

回答

0

是否要將圖像文件保存在您的設備中或您想要的內容。

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

或者您需要將它保存在手機中。

// DownloadImage的AsyncTask 私有類DownloadImage擴展的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

我想與其他應用程序共享該圖像 –

+0

我不明白你在做什麼..!你想要在應用程序中顯示圖像或分享像其他人喜歡的應用程序的圖像 – 2017-04-04 09:35:42