1. Are you ready for the Galaxy S20? Here is everything we know so far!

how to make Asyctask keep update the image

Discussion in 'Android Development' started by mozart0127, Oct 20, 2014.

  1. mozart0127

    mozart0127 Lurker
    Thread Starter

    I am using socket to transfer image between two device. In the server side, I am sent different image every 5 sec, in the client side, I need keep update in my image view. I am doing fine to receive one image, but Idk how to make it update.
    [HIGH]public class connection extends AsyncTask<Void,Void,Bitmap> {


    @Override
    protected Bitmap doInBackground(Void... params) {
    bitmaps=new ArrayList<Bitmap>();

    try {
    clientSocket = new Socket("134.129.125.126", 8080);
    System.out.println("client connect to server");
    input = clientSocket.getInputStream();
    System.out.println("getinputstream");
    } catch (UnknownHostException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }


    return bMap= BitmapFactory.decodeStream(input);



    }
    @Override
    protected void onPostExecute(Bitmap result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);

    image.setImageBitmap(result);


    }

    }[/HIGH]
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - Asyctask keep update
  1. godlovingman
    Replies:
    6
    Views:
    604
  2. Milo Williamson
    Replies:
    8
    Views:
    715
  3. TheManWithTheGoldenGun
    Replies:
    2
    Views:
    508
  4. DavidePrato
    Replies:
    4
    Views:
    669
  5. Soapm
    Replies:
    11
    Views:
    940
  6. Kosarar
    Replies:
    5
    Views:
    767
  7. ProfessorD
    Replies:
    3
    Views:
    797
  8. alepabrahao
    Replies:
    1
    Views:
    995
  9. metroidRoid2
    Replies:
    6
    Views:
    1,881
  10. alexhob123
    Replies:
    12
    Views:
    862

Share This Page

Loading...