Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_mostrar_datos);
- new BackgroundTask()
- .execute("https://i.ytimg.com/vi/AyM5sjRpwGk/hqdefault.jpg");
- }
- @Override
- protected Bitmap doInBackground(String... urls) {
- Bitmap bm = null;
- try {
- URL _url = new URL(urls[0]);
- URLConnection con = _url.openConnection();
- con.connect();
- InputStream is = con.getInputStream();
- BufferedInputStream bis = new BufferedInputStream(is);
- bm = BitmapFactory.decodeStream(bis);
- bis.close();
- is.close();
- } catch (Exception e) {
- Log.e(MainActivity.class.toString(), e.getMessage());
- }
- return bm;
- }
- @Override
- protected void onPostExecute(Bitmap result) {
- MostrarDatos.this.imagen.setImageBitmap(result);
- MostrarDatos.this.imagen.setVisibility(View.VISIBLE);
- String imagen = "https://i.ytimg.com/vi/AyM5sjRpwGk/hqdefault.jpg";
- new BackgroundTask()
- .execute(imagen);
- public class mICLASE extends AppCompatActivity {
- String imagen = "https://i.ytimg.com/vi/AyM5sjRpwGk/hqdefault.jpg";
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_mostrar_datos);
- new BackgroundTask()
- .execute(imagen);
- }
- }
Add Comment
Please, Sign In to add comment