我想從服務器上存儲的URL中獲取圖像的URI。 我試過這個。 uri = new URI(「http://www.google.com/」);如何從網址獲取圖像的Uri?
和
RI URI = Uri.parse( 「http://www.facebook.com」);
我想從服務器上存儲的URL中獲取圖像的URI。 我試過這個。 uri = new URI(「http://www.google.com/」);如何從網址獲取圖像的Uri?
和
RI URI = Uri.parse( 「http://www.facebook.com」);
是否要將圖像文件保存在您的設備中或您想要的內容。
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();
}
}
我想與其他應用程序共享該圖像 –
我不明白你在做什麼..!你想要在應用程序中顯示圖像或分享像其他人喜歡的應用程序的圖像 – 2017-04-04 09:35:42
無論http://www.google.com/也不http://www.facebook.com/有效圖像的URI –
是什麼你的代碼有錯?你沒有告訴。事實上,這不是一個圖像網址。但無關緊要。 – greenapps