void TestUrlConnectionStream(TextView textview) { Java.Net.URL url = new Java.Net.URL("http://www.google.pt/logos/classicplus.png"); Java.Net.URLConnection urlConnection = url.OpenConnection(); Android.Graphics.BitmapFactory.DecodeStream(urlConnection.InputStream); textview.Text += "\n\nOpened Url connection stream and loaded image"; }
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params) { Java.Net.URL url; try { url = new Java.Net.URL(_imageSource); BitMapShown = Android.Graphics.BitmapFactory.DecodeStream(url.OpenConnection().InputStream); } catch (Exception ignored) { Android.Util.Log.Error(TAG, "Exception", ignored); } return(BitMapShown); }
private Bitmap GetImageBitmapFromUrl(String url) { Bitmap bm = null; Java.Net.URL aURL = new Java.Net.URL(url); Java.Net.HttpURLConnection conn = (Java.Net.HttpURLConnection)aURL.OpenConnection(); conn.Connect(); Stream stream = conn.InputStream; BufferedStream bsteam = new BufferedStream(stream); bm = BitmapFactory.DecodeStream(bsteam); bsteam.Close(); stream.Close(); return(bm); }
private int GetFileSize(string fileUrl) { using (var url = new Java.Net.URL(fileUrl)) { Java.Net.HttpURLConnection conn = null; try { conn = (Java.Net.HttpURLConnection)url.OpenConnection(); conn.RequestMethod = "HEAD"; return(conn.ContentLength); } catch (Java.IO.IOException e) { return(-1); } finally { conn.Disconnect(); } } }
protected async override void OnStart() { base.OnStart(); await _nickViewModel.GetLocation(); await _nickViewModel.GetItem(); _nickViewModel.GetStrings(); string nick = _nickViewModel.PickedNick.Name; string location = _nickViewModel.Location.Name; string item = _nickViewModel.Item.Name; _greetingsText.Text = _nickViewModel.GreetingString; _resultText.Text = _nickViewModel.ResultString; string ImageName = System.IO.Path.GetFileNameWithoutExtension(_nickViewModel.PickedNick.ImageName); int id = Resources.GetIdentifier(ImageName, "drawable", PackageName); _nicImage.SetImageResource(id); if (_nickViewModel.Location.Local) { ImageName = System.IO.Path.GetFileNameWithoutExtension(_nickViewModel.Location.ImageName); id = Resources.GetIdentifier(ImageName, "drawable", PackageName); _greetingsImage.SetImageResource(id); } else { try { Java.Net.URL locationUrl = new Java.Net.URL(_nickViewModel.Location.ImageName); Bitmap bitmap = BitmapFactory.DecodeStream(locationUrl.OpenConnection().InputStream); _greetingsImage.SetImageBitmap(bitmap); } catch ( Exception exc) { Console.WriteLine(exc.ToString()); } } ImageName = System.IO.Path.GetFileNameWithoutExtension(_nickViewModel.Item.ImageName); id = Resources.GetIdentifier(ImageName, "drawable", PackageName); _itemImage.SetImageResource(id); }