java.lang.NumberFormatException: For input string: "msf:126968" in android

504 views Asked by At

So i am gettting this error while trying to get the images from gallery in my code. So i am getting the images and using sillicompressor library to compress the images and i m getting this error on this compression line

" File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp" + i)));"

Code

    activityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
        @Override
        public void onActivityResult(ActivityResult result) {


            if (result.getResultCode() == RESULT_OK && null != result.getData()) {

                if (result.getData().getClipData() != null) {
                    int countofImages = result.getData().getClipData().getItemCount();


                        //this part is to select multiple images
                        for (int i = 0; i < countofImages; i++) {

                            if (imageList.size() < 8)
                            {
                                 imageuri = result.getData().getClipData().getItemAt(i).getUri();

                                File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp" + i)));
                                compresseduri = Uri.fromFile(file);


                                imageList.add(new CustomModel(getfilename(imageuri), compresseduri));
                            } else
                                {
                                Toast.makeText(getContext(), "Can't select more than 8 images", Toast.LENGTH_SHORT).show();
                            }
                        }
                        //then notify the adapter
                    adapter.notifyDataSetChanged();
                    rentSell3Binding.totalphotos.setText("Photos (" + imageList.size() + ")");

                    }
                    //this part is to select single image
                    else {
                    if (imageList.size()<8) {
                         imageuri = result.getData().getData();

                        File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp")));

                        compresseduri = Uri.fromFile(file);

                        imageList.add(new CustomModel(getfilename(imageuri), compresseduri));

                    }else
                    {

                        Toast.makeText(getContext(), "Can't select more than 8 images", Toast.LENGTH_SHORT).show();

                    }

                    //notify the adapter
                    adapter.notifyDataSetChanged();
                    rentSell3Binding.totalphotos.setText("Photos (" + imageList.size() + ")");

                    }
            } 

Error i am getting

 java.lang.NumberFormatException: For input string: "msf:126968" on this line 
     File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp" + i)));"
0

There are 0 answers