Advertisement
SuroorAhmmad

screenshot

Mar 9th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. private class MyTask extends AsyncTask<Void, Void, Bitmap>{
  2.         @SuppressWarnings("deprecation")
  3.         @Override
  4.         protected void onPostExecute(Bitmap result) {
  5.             if(bitmap!=null){
  6.                 iv=(ImageView) findViewById(R.id.screenView);
  7.                 ob=new BitmapDrawable(getResources(),bitmap);
  8.                 iv.setBackgroundDrawable(ob);
  9.             }else{
  10.                 Log.d("Bitmap null","Empty");
  11.             }
  12.             MyTask task=new MyTask();
  13.             task.execute();
  14.         }
  15.  
  16.         @Override
  17.         protected Bitmap doInBackground(Void... arg0){
  18.             try {
  19.                 ObjectInputStream ois=new ObjectInputStream(client.getInputStream());
  20.                 byte[] buffer=(byte[]) ois.readObject();
  21.                 BitmapFactory.Options options=new BitmapFactory.Options();
  22.                 options.inMutable=true;
  23.                 bitmap = BitmapFactory.decodeByteArray(buffer, 0, buffer.length,options);
  24.                 return bitmap;
  25.             } catch (UnknownHostException e) {
  26.                 e.printStackTrace();
  27.             } catch (IOException e) {
  28.                 e.printStackTrace();
  29.             } catch (ClassNotFoundException e) {
  30.                 e.printStackTrace();
  31.             }
  32.             return null;
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement