Guest User

Untitled

a guest
Jan 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. protected void onCreate(Bundle savedInstanceState) {
  2. super.onCreate(savedInstanceState);
  3. setContentView(R.layout.activity_mostrar_datos);
  4.  
  5. new BackgroundTask()
  6. .execute("https://i.ytimg.com/vi/AyM5sjRpwGk/hqdefault.jpg");
  7.  
  8. }
  9.  
  10. @Override
  11. protected Bitmap doInBackground(String... urls) {
  12. Bitmap bm = null;
  13. try {
  14. URL _url = new URL(urls[0]);
  15. URLConnection con = _url.openConnection();
  16. con.connect();
  17. InputStream is = con.getInputStream();
  18. BufferedInputStream bis = new BufferedInputStream(is);
  19. bm = BitmapFactory.decodeStream(bis);
  20. bis.close();
  21. is.close();
  22. } catch (Exception e) {
  23. Log.e(MainActivity.class.toString(), e.getMessage());
  24. }
  25. return bm;
  26. }
  27.  
  28. @Override
  29. protected void onPostExecute(Bitmap result) {
  30. MostrarDatos.this.imagen.setImageBitmap(result);
  31. MostrarDatos.this.imagen.setVisibility(View.VISIBLE);
  32.  
  33. String imagen = "https://i.ytimg.com/vi/AyM5sjRpwGk/hqdefault.jpg";
  34.  
  35. new BackgroundTask()
  36. .execute(imagen);
  37.  
  38. public class mICLASE extends AppCompatActivity {
  39.  
  40. String imagen = "https://i.ytimg.com/vi/AyM5sjRpwGk/hqdefault.jpg";
  41.  
  42. protected void onCreate(Bundle savedInstanceState) {
  43. super.onCreate(savedInstanceState);
  44. setContentView(R.layout.activity_mostrar_datos);
  45.  
  46. new BackgroundTask()
  47. .execute(imagen);
  48.  
  49. }
  50.  
  51. }
Add Comment
Please, Sign In to add comment