viewing paste Unknown #6746 | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
  listView1.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Log.v("Module Item Trigger", "Module item was triggered");
                   
                   //checkim is the byte array of the image to be passed to another activity or URL of the image whatever is best.
 
               Bundle bundle = new Bundle();
                   bundle.putByteArray("image", checkim);
                   myintent.putExtras(bundle);
                   startActivity(myintent);
                   
                
    }
            });
        
        
 
//This is the API method for getting a image from the server it brings image in byte array and i add this to listview by making it as a bitmap.
I want this image to be passed to another activity when pressed.
 
 @Override
                public void onBinaryMessage(byte[] image)
                {
                
                
                Bitmap receivedImage=BitmapFactory.decodeByteArray(image,0,image.length);
                    float scale=1;
                
                int width  = receivedImage.getWidth();
                    int height = receivedImage.getHeight();
                    float scaleHeight = (float)height/(float)200;
                    float scaleWidth  = (float)width /(float)200;
                    if (scaleWidth < scaleHeight) 
                        {scale = scaleHeight;}
                    else
                    {
                        scale = scaleWidth;
                    }
                    
                   Bitmap bitmaped = Bitmap.createScaledBitmap(receivedImage, (int)(width/scale), (int)(height/scale), true);
                addImage(new Message(bitmaped,false,false));
                
                }
                
 
//Another image which is to be passed when clicked is from my photo gallery when selected and populated in the listview like this 
 
 
 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            
            if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
                Uri selectedImage = data.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };
 
                Cursor cursor = getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
                cursor.moveToFirst();
 
                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String picturePath = cursor.getString(columnIndex);
                cursor.close();
                Bitmap fileimage =BitmapFactory.decodeFile(picturePath);
                 float scale=1;
                
                int width  = fileimage.getWidth();
                    int height = fileimage.getHeight();
                    float scaleHeight = (float)height/(float)300;
                    float scaleWidth  = (float)width /(float)300;
                    if (scaleWidth < scaleHeight) 
                        {scale = scaleHeight;}
                    else
                    {
                        scale = scaleWidth;
                    }
                    
                   Bitmap bitmap = Bitmap.createScaledBitmap(fileimage, (int)(width/scale), (int)(height/scale), true);
                
                     
                   ByteArrayOutputStream stream = new ByteArrayOutputStream();
                   bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
                   byte[] byteArray = stream.toByteArray();
                   
                   //checkim=stream.toByteArray();
                   //System.out.println("checkim is instantiated"+checkim.toString());
                   mConnection.sendBinaryMessage(byteArray);
                   
                   
                   
                       
                   
                
                    addImage(new Message(bitmap,true,false));
            
            }
     }
 
 
Viewed 953 times, submitted by Guest.