Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class MyTask extends AsyncTask<Void, Void, Bitmap>{
- @SuppressWarnings("deprecation")
- @Override
- protected void onPostExecute(Bitmap result) {
- if(bitmap!=null){
- iv=(ImageView) findViewById(R.id.screenView);
- ob=new BitmapDrawable(getResources(),bitmap);
- iv.setBackgroundDrawable(ob);
- }else{
- Log.d("Bitmap null","Empty");
- }
- MyTask task=new MyTask();
- task.execute();
- }
- @Override
- protected Bitmap doInBackground(Void... arg0){
- try {
- ObjectInputStream ois=new ObjectInputStream(client.getInputStream());
- byte[] buffer=(byte[]) ois.readObject();
- BitmapFactory.Options options=new BitmapFactory.Options();
- options.inMutable=true;
- bitmap = BitmapFactory.decodeByteArray(buffer, 0, buffer.length,options);
- return bitmap;
- } catch (UnknownHostException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement