Use entered URL and button to display image from URL
<p>This is my first time posting, and after entering my title, I have gone through every relevant question and am still having troubles. 
Plain and simple, person enters image url into and EditText, they hit a button, the image appears under the button. I am using BitmapFactory and need to keep it that way. I also have the AndroidManifest.xml already includes the appropriate INTERNET permission.</p>

<p>The Java is as so:</p>

<pre><code>package com.display.picture;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import android.app.Activity;
import android.os.Bundle;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

public class DisplayPictureActivity extends Activity {

    private EditText et;
    private Button btn;
    private ImageView iv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        et = (EditText) findViewById(R.id.et1);
        iv = (ImageView) findViewById(R.id.iv1);
        btn = (Button) findViewById(R.id.btn1);

        btn.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                try
                {
                    URL url = new URL(et.getText().toString());
                    URLConnection connection = url.openConnection();
                    connection.connect();
                    InputStream is = connection.getInputStream();
                    BufferedInputStream bis = new BufferedInputStream(is);
                    Bitmap bitmap = BitmapFactory.decodeStream(bis);
                    ImageView myImage = (ImageView) findViewById(R.id.iv1);
                    myImage.setImageBitmap(bitmap);
                    bis.close();
                    is.close();
                }
                catch (Exception e) {
                    Toast toast = Toast.makeText(getBaseContext(), "Failed to Download Image", Toast.LENGTH_LONG);
                    toast.show();
                }
                Bitmap image = null;
                iv.setImageBitmap(image);
            }
        });
    }
}
</code></pre>

<p>The majority of the questions I see here involve having hard-coded hyperlinks. While here I'm supposed to allow the user to enter an image url and then pass that through the Bitmap, and display it within an imageview after hitting a button</p>

<p>My manifest:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.display.picture"
      android:versionCode="1"
      android:versionName="1.0"&gt;
    &lt;uses-sdk android:minSdkVersion="8" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;

    &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
        &lt;activity android:name=".DisplayPictureActivity"
                  android:label="@string/app_name"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
&lt;/manifest&gt;
</code></pre>
